Esempio n. 1
0
        def test_account_author_can_update_his_account(self, api_client):
            new_user = UserFactory()
            api_client.force_authenticate(new_user)
            data = {'email': '*****@*****.**', 'name': 'test'}
            response = api_client.patch(new_user.get_absolute_url(), data)

            assert response.status_code == 200
Esempio n. 2
0
        def test_user1_cant_delete_user2_account(self, api_client):
            new_user = UserFactory()
            new_user2 = UserFactory()
            api_client.force_authenticate(new_user)
            response = api_client.delete(new_user2.get_absolute_url())

            assert response.status_code == 403
Esempio n. 3
0
def test_get_absolute_url():
    new_user = UserFactory()

    assert new_user.get_absolute_url() == f'/api/accounts/{new_user.id}/'
Esempio n. 4
0
        def test_guest_cant_update_othes_accounts(self, api_client):
            new_user = UserFactory()
            data = {'email': '*****@*****.**', 'name': 'test'}
            response = api_client.patch(new_user.get_absolute_url(), data)

            assert response.status_code == 401
Esempio n. 5
0
        def test_guest_cant_delete_others_accounts(self, api_client):
            new_user = UserFactory()
            response = api_client.delete(new_user.get_absolute_url())

            assert response.status_code == 401
Esempio n. 6
0
        def test_account_author_can_delete_his_account(self, api_client):
            new_user = UserFactory()
            api_client.force_authenticate(new_user)
            response = api_client.delete(new_user.get_absolute_url())

            assert response.status_code == 204
Esempio n. 7
0
        def test_user_detail_page_render(self, api_client):
            new_user = UserFactory()
            response = api_client.get(new_user.get_absolute_url())

            assert response.status_code == 200