Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Python Briar Wrapper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
Python Briar Wrapper
Commits
3235ec0b
Commit
3235ec0b
authored
4 years ago
by
Nico
Browse files
Options
Downloads
Patches
Plain Diff
Support deleting contacts
Fixes
#16
parent
514290c5
Loading
Loading
No related merge requests found
Pipeline
#4748
failed
4 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
briar_wrapper/models/contacts.py
+14
-0
14 additions, 0 deletions
briar_wrapper/models/contacts.py
tests/briar_wrapper/models/test_contacts.py
+10
-0
10 additions, 0 deletions
tests/briar_wrapper/models/test_contacts.py
with
24 additions
and
0 deletions
briar_wrapper/models/contacts.py
+
14
−
0
View file @
3235ec0b
...
@@ -8,6 +8,7 @@ Wrapper around Briar API's _/contacts/_ resource
...
@@ -8,6 +8,7 @@ Wrapper around Briar API's _/contacts/_ resource
from
operator
import
itemgetter
from
operator
import
itemgetter
from
urllib.parse
import
urljoin
from
urllib.parse
import
urljoin
from
requests
import
delete
as
_delete
from
requests
import
get
as
_get
from
requests
import
get
as
_get
from
requests
import
post
as
_post
from
requests
import
post
as
_post
...
@@ -35,6 +36,19 @@ class Contacts(Model):
...
@@ -35,6 +36,19 @@ class Contacts(Model):
url
=
urljoin
(
BASE_HTTP_URL
,
self
.
_API_ENDPOINT
+
"
add/pending/
"
)
url
=
urljoin
(
BASE_HTTP_URL
,
self
.
_API_ENDPOINT
+
"
add/pending/
"
)
_post
(
url
,
headers
=
self
.
_headers
,
json
=
{
"
link
"
:
link
,
"
alias
"
:
alias
})
_post
(
url
,
headers
=
self
.
_headers
,
json
=
{
"
link
"
:
link
,
"
alias
"
:
alias
})
def
delete
(
self
,
contact_id
):
# pylint: disable=line-too-long
"""
Deletes the contact with `contact_id`
[Upstream documentation](https://code.briarproject.org/briar/briar/blob/master/briar-headless/README.md#removing-a-contact)
.. versionadded:: 0.0.4
"""
url
=
urljoin
(
BASE_HTTP_URL
,
self
.
API_ENDPOINT
+
str
(
contact_id
))
_delete
(
url
,
headers
=
self
.
_headers
)
def
get
(
self
):
def
get
(
self
):
# pylint: disable=line-too-long
# pylint: disable=line-too-long
"""
"""
...
...
This diff is collapsed.
Click to expand it.
tests/briar_wrapper/models/test_contacts.py
+
10
−
0
View file @
3235ec0b
...
@@ -48,6 +48,16 @@ def match_request_add_pending(request):
...
@@ -48,6 +48,16 @@ def match_request_add_pending(request):
return
{
"
alias
"
:
TEST_ALIAS
,
"
link
"
:
TEST_LINK
}
==
request
.
json
()
return
{
"
alias
"
:
TEST_ALIAS
,
"
link
"
:
TEST_LINK
}
==
request
.
json
()
@requests_mock.Mocker
(
kw
=
"
requests_mock
"
)
def
test_delete
(
api
,
request_headers
,
requests_mock
):
contacts
=
Contacts
(
api
)
contact_id
=
137
requests_mock
.
register_uri
(
"
DELETE
"
,
BASE_HTTP_URL
+
str
(
contact_id
),
request_headers
=
request_headers
)
contacts
.
delete
(
contact_id
)
@requests_mock.Mocker
(
kw
=
'
requests_mock
'
)
@requests_mock.Mocker
(
kw
=
'
requests_mock
'
)
def
test_get
(
api
,
request_headers
,
requests_mock
):
def
test_get
(
api
,
request_headers
,
requests_mock
):
contacts
=
Contacts
(
api
)
contacts
=
Contacts
(
api
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment