def test_get_project_unauthorized(): client = APIClient() project, _ = get_project() url = reverse('project', args=(project.id, )) resp = client.get(path=url) assert resp.status_code == 403
def test_patch_project_not_valid(admin_client): project, _ = get_project() url = reverse('project', args=(project.id, )) not_valid_body = {'project_manager': 'NOT_VALID_DATA'} resp = admin_client.patch(url, data=not_valid_body, format='json') assert resp.status_code == 400
def test_put_project_unauthorized(): client = APIClient() project, valid_body = get_project() url = reverse('project', args=(project.id, )) resp = client.put(url, data=valid_body, format='json') assert resp.status_code == 403
def test_put_project_object_does_not_exist(admin_client): project_not_exist_pk = 999 _, valid_body = get_project() url = reverse('project', args=(project_not_exist_pk, )) resp = admin_client.put(url, data=valid_body, format='json') assert resp.status_code == 404
def test_put_project_not_valid(admin_client): project, body = get_project() url = reverse('project', args=(project.id, )) body['project_manager'] = 'NOT_VALID_DATA' resp = admin_client.put(url, data=body, format='json') assert resp.status_code == 400
def test_patch_project_unauthorized(): client = APIClient() project, _ = get_project() url = reverse('project', args=(project.id, )) patch_body = {'name': 'IT Department'} resp = client.patch(url, data=patch_body, format='json') assert resp.status_code == 403
def test_patch_project_success(admin_client): project, _ = get_project() url = reverse('project', args=(project.id, )) patch_body = {'name': 'IT Project'} resp = admin_client.patch(url, data=patch_body, format='json') assert resp.status_code == 200 assert resp.data['name'] == patch_body['name']
def test_put_project_success(admin_client): project, body = get_project() url = reverse('project', args=(project.id, )) new_name = 'IT Project' body['name'] = new_name resp = admin_client.put(url, data=body, format='json') assert resp.status_code == 200 assert resp.data['name'] == new_name
def test_get_project_success(admin_client): project, _ = get_project() url = reverse('project', args=(project.id, )) resp = admin_client.get(path=url) assert 200 == resp.status_code