Skip to content

Commit c235d6c

Browse files
committed
fix tests
1 parent 9f765a7 commit c235d6c

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

api_tests/registrations/views/test_registration_detail.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -755,14 +755,14 @@ def test_initiate_withdraw_registration_fails(
755755
res = app.put_json_api(public_url, public_payload, auth=user.auth, expect_errors=True)
756756
assert res.status_code == 400
757757

758-
def test_initiate_withdrawal_success(self, mock_notification_send, app, user, public_registration, public_url, public_payload):
758+
def test_initiate_withdrawal_success(self, mock_send_grid, app, user, public_registration, public_url, public_payload):
759759
res = app.put_json_api(public_url, public_payload, auth=user.auth)
760760
assert res.status_code == 200
761761
assert res.json['data']['attributes']['pending_withdrawal'] is True
762762
public_registration.refresh_from_db()
763763
assert public_registration.is_pending_retraction
764764
assert public_registration.registered_from.logs.first().action == 'retraction_initiated'
765-
assert mock_notification_send.called
765+
assert mock_send_grid.called
766766

767767
@pytest.mark.usefixtures('mock_gravy_valet_get_verified_links')
768768
def test_initiate_withdrawal_with_embargo_ends_embargo(
@@ -787,7 +787,7 @@ def test_initiate_withdrawal_with_embargo_ends_embargo(
787787
assert not public_registration.is_pending_embargo
788788

789789
def test_withdraw_request_does_not_send_email_to_unregistered_admins(
790-
self, mock_notification_send, app, user, public_registration, public_url, public_payload):
790+
self, mock_send_grid, app, user, public_registration, public_url, public_payload):
791791
unreg = UnregUserFactory()
792792
with disconnected_from_listeners(contributor_added):
793793
public_registration.add_unregistered_contributor(
@@ -804,7 +804,7 @@ def test_withdraw_request_does_not_send_email_to_unregistered_admins(
804804

805805
# Only the creator gets an email; the unreg user does not get emailed
806806
assert public_registration._contributors.count() == 2
807-
assert mock_notification_send.call_count == 3
807+
assert mock_send_grid.call_count == 3
808808

809809

810810
@pytest.mark.django_db

api_tests/requests/views/test_request_detail.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from api_tests.requests.mixins import NodeRequestTestMixin, PreprintRequestTestMixin
55

66
@pytest.mark.django_db
7+
@pytest.mark.usefixtures('mock_notification_send')
78
class TestNodeRequestDetail(NodeRequestTestMixin):
89
@pytest.fixture()
910
def url(self, node_request):

api_tests/users/views/test_user_settings.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,14 @@ def url(self):
188188
def csrf_token(self):
189189
return csrf._mask_cipher_secret(csrf._get_new_csrf_string())
190190

191-
def test_get(self, mock_notification_send, app, url, user_one):
191+
def test_get(self, mock_send_grid, app, url, user_one):
192192
encoded_email = urllib.parse.quote(user_one.email)
193193
url = f'{url}?email={encoded_email}'
194194
res = app.get(url)
195195
assert res.status_code == 200
196196

197197
user_one.reload()
198-
assert mock_notification_send.called
198+
assert mock_send_grid.call_args[1]['to_addr'] == user_one.username
199199

200200
def test_get_invalid_email(self, mock_send_grid, app, url):
201201
url = f'{url}?email={'invalid_email'}'
@@ -268,8 +268,7 @@ def test_post_invalid_password(self, app, url, user_one, csrf_token):
268268
res = app.post_json_api(url, payload, expect_errors=True, headers={'X-THROTTLE-TOKEN': 'test-token', 'X-CSRFToken': csrf_token})
269269
assert res.status_code == 400
270270

271-
def test_throttle(self, app, url, user_one, csrf_token):
272-
app.set_cookie(CSRF_COOKIE_NAME, csrf_token)
271+
def test_throttle(self, app, url, user_one):
273272
encoded_email = urllib.parse.quote(user_one.email)
274273
url = f'{url}?email={encoded_email}'
275274
app.get(url)
@@ -283,12 +282,9 @@ def test_throttle(self, app, url, user_one, csrf_token):
283282
}
284283
}
285284
}
286-
res = app.post_json_api(url, payload, expect_errors=True, headers={'X-CSRFToken': csrf_token})
287-
assert res.status_code == 200
288-
289-
res = app.get(url, expect_errors=True)
290-
assert res.json['message'] == 'You have recently requested to change your password. Please wait a few minutes before trying again.'
291285

286+
res = app.post_json_api(url, payload, expect_errors=True)
287+
assert res.status_code == 429
292288

293289
@pytest.mark.django_db
294290
class TestUserEmailsList:

0 commit comments

Comments
 (0)