-
Notifications
You must be signed in to change notification settings - Fork 350
[ENG-9681] Fix api3 ci and collection submission issues #11410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Johnetordoff
wants to merge
22
commits into
CenterForOpenScience:feature/notification-refactor-p2-s
from
Johnetordoff:fix-api3-ci-and-collection-submission-issues
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b9a9445
add missing migrations
Johnetordoff f066051
[ENG-9193] Re-route unregistered contributor claim (#11377)
antkryt 2fa247b
Merge branch 'hotfix/25.17.8'
adlius f409206
Merge tag '25.17.8' into develop
adlius 56e065b
fix api3_and_osf ci
Ostap-Zherebetskyi bfad7ee
fix unit tests
Ostap-Zherebetskyi 3a836bb
Remove skipped tests
Ostap-Zherebetskyi a920785
[ENG-9619] Merge pull request #11385 from Ostap-Zherebetskyi/fix/api3-ci
brianjgeiger 4f5acbc
ENG-9127 add contributors from parent project to component
mkovalua 06715e2
implement unit test for component project contributors from parent pr…
mkovalua 6c49b78
Merge branch 'hotfix/25.17.9'
adlius 1dd3954
Merge tag '25.17.9' into develop
adlius a4cda76
fix api3 test branch and collection submission issues
Johnetordoff f855072
fix collections submissions tests in `api_tests/collection_submissions/`
Johnetordoff ee3985f
fix crossref email notification type mismatch
Johnetordoff 2a13d0c
fix TestCustomItemMetadataRecordDetail by using expect_errors=True,
Johnetordoff c4bee2c
mock action list tests
Johnetordoff ef76e96
mock collect object notifications
Johnetordoff f073c7b
Merge branch 'develop' of github.com:johnetordoff/osf.io into fix-api…
Johnetordoff 20d6682
add more mocking to collection submissions
Johnetordoff 5f63571
Merge branch 'develop' of https://github.com/centerforopenscience/osf…
Johnetordoff 6f133ba
fix throttle tests for notification refactor
Johnetordoff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| from django.utils import timezone | ||
| from osf_tests.factories import NodeFactory, CollectionFactory, CollectionProviderFactory | ||
|
|
||
| from osf.models import CollectionSubmission | ||
| from osf.models import CollectionSubmission, NotificationType | ||
| from osf.utils.workflows import CollectionSubmissionsTriggers, CollectionSubmissionStates | ||
| from tests.utils import capture_notifications | ||
|
|
||
|
|
@@ -33,8 +33,7 @@ def node(collection_provider): | |
| def collection(collection_provider): | ||
| collection = CollectionFactory() | ||
| collection.provider = collection_provider | ||
| with capture_notifications(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would fail because it didn't send notifications. |
||
| collection.save() | ||
| collection.save() | ||
| return collection | ||
|
|
||
|
|
||
|
|
@@ -122,10 +121,21 @@ def test_status_code__collection_moderator_accept_reject_moderated(self, app, no | |
| collection_submission.state_machine.set_state(CollectionSubmissionStates.PENDING) | ||
| collection_submission.save() | ||
| test_auth = configure_test_auth(node, UserRoles.MODERATOR) | ||
| resp = app.post_json_api(POST_URL, make_payload( | ||
| collection_submission=collection_submission, | ||
| trigger=moderator_trigger.db_name | ||
| ), auth=test_auth, expect_errors=True) | ||
| with capture_notifications() as notifications: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds needed email mocking. |
||
| resp = app.post_json_api( | ||
| POST_URL, | ||
| make_payload( | ||
| collection_submission=collection_submission, | ||
| trigger=moderator_trigger.db_name | ||
| ), | ||
| auth=test_auth, | ||
| expect_errors=True | ||
| ) | ||
| assert len(notifications['emits']) == 1 | ||
| if moderator_trigger is CollectionSubmissionsTriggers.ACCEPT: | ||
| assert notifications['emits'][0]['type'] == NotificationType.Type.COLLECTION_SUBMISSION_ACCEPTED | ||
| if moderator_trigger is CollectionSubmissionsTriggers.REJECT: | ||
| assert notifications['emits'][0]['type'] == NotificationType.Type.COLLECTION_SUBMISSION_REJECTED | ||
| assert resp.status_code == 201 | ||
|
|
||
| @pytest.mark.parametrize('moderator_trigger', [CollectionSubmissionsTriggers.ACCEPT, CollectionSubmissionsTriggers.REJECT]) | ||
|
|
@@ -158,11 +168,27 @@ def test_status_code__remove(self, app, node, collection_submission, user_role): | |
| collection_submission.state_machine.set_state(CollectionSubmissionStates.ACCEPTED) | ||
| collection_submission.save() | ||
| test_auth = configure_test_auth(node, user_role) | ||
| resp = app.post_json_api(POST_URL, make_payload( | ||
| collection_submission=collection_submission, | ||
| trigger=CollectionSubmissionsTriggers.REMOVE.db_name | ||
| ), auth=test_auth, expect_errors=True) | ||
| with capture_notifications() as notifications: | ||
| resp = app.post_json_api( | ||
| POST_URL, | ||
| make_payload( | ||
| collection_submission=collection_submission, | ||
| trigger=CollectionSubmissionsTriggers.REMOVE.db_name | ||
| ), | ||
| auth=test_auth, | ||
| expect_errors=True | ||
| ) | ||
| assert resp.status_code == 201 | ||
| if user_role == UserRoles.MODERATOR: | ||
| assert len(notifications['emits']) == 1 | ||
| assert notifications['emits'][0]['type'] == NotificationType.Type.COLLECTION_SUBMISSION_REMOVED_MODERATOR | ||
| assert notifications['emits'][0]['kwargs']['user'] == collection_submission.creator | ||
| else: | ||
| assert len(notifications['emits']) == 2 | ||
| assert notifications['emits'][0]['type'] == NotificationType.Type.COLLECTION_SUBMISSION_REMOVED_ADMIN | ||
| assert notifications['emits'][0]['kwargs']['user'] == collection_submission.creator | ||
| assert notifications['emits'][1]['type'] == NotificationType.Type.COLLECTION_SUBMISSION_REMOVED_ADMIN | ||
| assert notifications['emits'][1]['kwargs']['user'] == node.contributors.last() | ||
|
|
||
|
|
||
| @pytest.mark.django_db | ||
|
|
@@ -182,11 +208,14 @@ def test_POST_accept__writes_action_and_advances_state(self, app, collection_sub | |
| collection_submission.save() | ||
| test_auth = configure_test_auth(node, UserRoles.MODERATOR) | ||
| payload = make_payload(collection_submission, trigger=CollectionSubmissionsTriggers.ACCEPT.db_name) | ||
| app.post_json_api(POST_URL, payload, auth=test_auth) | ||
| with capture_notifications() as notifications: | ||
| app.post_json_api(POST_URL, payload, auth=test_auth) | ||
| assert len(notifications['emits']) == 1 | ||
| assert notifications['emits'][0]['type'] == NotificationType.Type.COLLECTION_SUBMISSION_ACCEPTED | ||
|
|
||
| user = collection_submission.collection.provider.get_group('moderator').user_set.first() | ||
| collection_submission.refresh_from_db() | ||
| action = collection_submission.actions.last() | ||
|
|
||
| assert action.trigger == CollectionSubmissionsTriggers.ACCEPT | ||
| assert action.creator == user | ||
| assert action.from_state == CollectionSubmissionStates.PENDING | ||
|
|
@@ -198,11 +227,14 @@ def test_POST_reject__writes_action_and_advances_state(self, app, collection_sub | |
| collection_submission.save() | ||
| test_auth = configure_test_auth(node, UserRoles.MODERATOR) | ||
| payload = make_payload(collection_submission, trigger=CollectionSubmissionsTriggers.REJECT.db_name) | ||
| app.post_json_api(POST_URL, payload, auth=test_auth) | ||
| with capture_notifications() as notifications: | ||
| app.post_json_api(POST_URL, payload, auth=test_auth) | ||
| assert len(notifications['emits']) == 1 | ||
| assert notifications['emits'][0]['type'] == NotificationType.Type.COLLECTION_SUBMISSION_REJECTED | ||
|
|
||
| user = collection_submission.collection.provider.get_group('moderator').user_set.first() | ||
| collection_submission.refresh_from_db() | ||
| action = collection_submission.actions.last() | ||
|
|
||
| assert action.trigger == CollectionSubmissionsTriggers.REJECT | ||
| assert action.creator == user | ||
| assert action.from_state == CollectionSubmissionStates.PENDING | ||
|
|
@@ -214,7 +246,14 @@ def test_POST_cancel__writes_action_and_advances_state(self, app, collection_sub | |
| collection_submission.save() | ||
| test_auth = configure_test_auth(node, UserRoles.ADMIN_USER) | ||
| payload = make_payload(collection_submission, trigger=CollectionSubmissionsTriggers.CANCEL.db_name) | ||
| app.post_json_api(POST_URL, payload, auth=test_auth) | ||
| with capture_notifications() as notifications: | ||
| app.post_json_api(POST_URL, payload, auth=test_auth) | ||
| assert len(notifications['emits']) == 2 | ||
| assert notifications['emits'][0]['type'] == NotificationType.Type.COLLECTION_SUBMISSION_CANCEL | ||
| assert notifications['emits'][0]['kwargs']['user'] == collection_submission.creator | ||
| assert notifications['emits'][1]['type'] == NotificationType.Type.COLLECTION_SUBMISSION_CANCEL | ||
| assert notifications['emits'][0]['kwargs']['user'] == node.creator | ||
|
|
||
| collection_submission.refresh_from_db() | ||
| action = collection_submission.actions.last() | ||
|
|
||
|
|
@@ -229,7 +268,10 @@ def test_POST_remove__writes_action_and_advances_state(self, app, collection_sub | |
| collection_submission.save() | ||
| test_auth = configure_test_auth(node, UserRoles.MODERATOR) | ||
| payload = make_payload(collection_submission, trigger=CollectionSubmissionsTriggers.REMOVE.db_name) | ||
| app.post_json_api(POST_URL, payload, auth=test_auth) | ||
| with capture_notifications() as notifications: | ||
| app.post_json_api(POST_URL, payload, auth=test_auth) | ||
| assert len(notifications['emits']) == 1 | ||
| assert notifications['emits'][0]['type'] == NotificationType.Type.COLLECTION_SUBMISSION_REMOVED_MODERATOR | ||
| user = collection_submission.collection.provider.get_group('moderator').user_set.first() | ||
| collection_submission.refresh_from_db() | ||
| action = collection_submission.actions.last() | ||
|
|
@@ -269,15 +311,18 @@ def test_status_code__private_collection_moderator(self, app, node, collection, | |
| collection.is_public = False | ||
| collection.save() | ||
| test_auth = configure_test_auth(node, UserRoles.MODERATOR) | ||
| resp = app.post_json_api( | ||
| POST_URL, | ||
| make_payload( | ||
| collection_submission, | ||
| trigger=CollectionSubmissionsTriggers.ACCEPT.db_name | ||
| ), | ||
| auth=test_auth, | ||
| expect_errors=True | ||
| ) | ||
| with capture_notifications() as notifications: | ||
| resp = app.post_json_api( | ||
| POST_URL, | ||
| make_payload( | ||
| collection_submission, | ||
| trigger=CollectionSubmissionsTriggers.ACCEPT.db_name | ||
| ), | ||
| auth=test_auth, | ||
| expect_errors=True | ||
| ) | ||
| assert len(notifications['emits']) == 1 | ||
| assert notifications['emits'][0]['type'] == NotificationType.Type.COLLECTION_SUBMISSION_ACCEPTED | ||
| assert resp.status_code == 201 | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would fail because it didn't send notifications.