Пример #1
0
    def test_unauthenticated(self, client, user_factory):
        user = user_factory()

        mutation = MutationGenerator.change_password(user_id=user.id,
                                                     old_password='******',
                                                     new_password='******')
        response = client.post('/graphql', {'query': mutation})

        assert response.status_code == 200, response.content
        assert not response.json()['data']['changePassword']
        assert response.json()['errors'][0]['message'] == 'Unauthorized'
Пример #2
0
    def test_valid(self, superuser_client, user_factory):
        user = user_factory()

        mutation = MutationGenerator.change_password(user_id=user.id,
                                                     old_password='******',
                                                     new_password='******')
        response = superuser_client.post('/graphql', {'query': mutation})

        assert response.status_code == 200, response.content
        assert response.json(
        )['data']['changePassword']['user']['email'] == user.email
Пример #3
0
    def test_invalid_password(self, superuser_client, user_factory):
        user = user_factory()

        mutation = MutationGenerator.change_password(user_id=user.id,
                                                     old_password='******',
                                                     new_password='******')
        response = superuser_client.post('/graphql', {'query': mutation})

        assert response.status_code == 200, response.content
        assert not response.json()['data']['changePassword']
        assert response.json()['errors'][0]['message'] == str(
            {'old_password': ['Wrong password.']})
Пример #4
0
    def test_invalid_id(self, superuser_client, user_factory):
        user = user_factory()

        mutation = MutationGenerator.change_password(user_id=user.id + 1,
                                                     old_password='******',
                                                     new_password='******')
        response = superuser_client.post('/graphql', {'query': mutation})

        assert response.status_code == 200, response.content
        assert not response.json()['data']['changePassword']
        assert response.json(
        )['errors'][0]['message'] == 'User matching query does not exist.'