| @@ 50-62 (lines=13) @@ | ||
| 47 | ||
| 48 | @pytest.mark.django_db(transaction=False) |
|
| 49 | def test_invalid_serialize_request_not_existent_user(test_user): |
|
| 50 | request = mock.MagicMock() |
|
| 51 | request.data = { |
|
| 52 | 'uid': utils.encode_uid(test_user.pk + 1), |
|
| 53 | 'token': default_token_generator.make_token(test_user), |
|
| 54 | 'new_password': 'whatever-123', |
|
| 55 | } |
|
| 56 | context = {'request': request} |
|
| 57 | with pytest.raises(exceptions.ValidationError) as e: |
|
| 58 | pipelines.password_reset_confirm.serialize_request(**context) |
|
| 59 | ||
| 60 | assert e.value.errors == { |
|
| 61 | 'non_field_errors': [constants.INVALID_UID_ERROR] |
|
| 62 | } |
|
| 63 | ||
| 64 | ||
| 65 | @pytest.mark.django_db(transaction=False) |
|
| @@ 31-43 (lines=13) @@ | ||
| 28 | ||
| 29 | @pytest.mark.django_db(transaction=False) |
|
| 30 | def test_invalid_serialize_request_same_username(test_user): |
|
| 31 | request = mock.MagicMock() |
|
| 32 | request.user = test_user |
|
| 33 | request.data = { |
|
| 34 | User.USERNAME_FIELD: getattr(test_user, User.USERNAME_FIELD), |
|
| 35 | 'current_password': 'testing123', |
|
| 36 | } |
|
| 37 | context = {'request': request} |
|
| 38 | with pytest.raises(exceptions.ValidationError) as e: |
|
| 39 | pipelines.username_update.serialize_request(**context) |
|
| 40 | ||
| 41 | assert e.value.errors == { |
|
| 42 | 'username': ['A user with that username already exists.'] |
|
| 43 | } |
|
| 44 | ||
| 45 | ||
| 46 | @pytest.mark.django_db(transaction=False) |
|