forked from CenterForOpenScience/osf.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
257 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import contextlib | ||
from urllib.parse import urlsplit | ||
|
||
from django.http import QueryDict | ||
|
||
from website import settings as website_settings | ||
|
||
|
||
@contextlib.contextmanager | ||
def expect_ingest_request(mock_share, osfguid, *, token=None, delete=False, count=1): | ||
mock_share._calls.reset() | ||
yield | ||
assert len(mock_share.calls) == count | ||
for _call in mock_share.calls: | ||
assert_ingest_request(_call.request, osfguid, token=token, delete=delete) | ||
|
||
|
||
def assert_ingest_request(request, expected_osfguid, *, token=None, delete=False): | ||
_querydict = QueryDict(urlsplit(request.path_url).query) | ||
assert _querydict['record_identifier'] == expected_osfguid | ||
if delete: | ||
assert request.method == 'DELETE' | ||
else: | ||
assert request.method == 'POST' | ||
assert _querydict['focus_iri'] == f'{website_settings.DOMAIN}{expected_osfguid}' | ||
_token = token or website_settings.SHARE_API_TOKEN | ||
assert request.headers['Authorization'] == f'Bearer {_token}' |
Oops, something went wrong.