Skip to content

Commit

Permalink
test(backend): project summaries and project by id (#1611)
Browse files Browse the repository at this point in the history
  • Loading branch information
azharcodeit authored Jun 28, 2024
1 parent 319f65e commit d2790de
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/backend/tests/test_projects_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit d2790de

Please sign in to comment.