예제 #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.'