From d2790de8b651116641f1851e542fea6afffb9053 Mon Sep 17 00:00:00 2001 From: Azhar Ismagulova <31756707+azharcodeit@users.noreply.github.com> Date: Fri, 28 Jun 2024 20:41:51 +0100 Subject: [PATCH] test(backend): project summaries and project by id (#1611) --- src/backend/tests/test_projects_routes.py | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/backend/tests/test_projects_routes.py b/src/backend/tests/test_projects_routes.py index 4e839fa1b..c10121682 100644 --- a/src/backend/tests/test_projects_routes.py +++ b/src/backend/tests/test_projects_routes.py @@ -321,6 +321,50 @@ async def test_update_project(client, admin_user, project): ) +async def test_project_summaries(client, project): + """Test read project summaries.""" + response = client.get("/projects/summaries") + assert response.status_code == 200 + assert "results" in response.json() + + results = response.json()["results"] + result = results[0] + + assert result["id"] == project.id + assert result["title"] == project.title + assert result["description"] == project.description + assert result["hashtags"] == project.hashtags + assert result["organisation_id"] == project.organisation_id + + +async def test_project_by_id(client, project): + """Test read project by id.""" + response = client.get(f"projects/{project.id}") + assert response.status_code == 200 + + data = response.json() + + assert data["id"] == project.id + assert data["odkid"] == project.odkid + assert data["author"]["username"] == project.author.username + assert data["author"]["id"] == project.author.id + assert data["project_info"]["name"] == project.project_info.name + assert ( + data["project_info"]["short_description"] + == project.project_info.short_description + ) + assert data["project_info"]["description"] == project.project_info.description + assert ( + data["project_info"]["per_task_instructions"] + == project.project_info.per_task_instructions + ) + assert data["status"] == project.status + assert data["xform_category"] == project.xform_category + assert data["hashtags"] == project.hashtags + assert data["organisation_id"] == project.organisation_id + assert data["tasks"] == project.tasks + + if __name__ == "__main__": """Main func if file invoked directly.""" pytest.main()