Skip to content

Commit

Permalink
feat: added test for update project routes
Browse files Browse the repository at this point in the history
  • Loading branch information
azharcodeit committed Jun 10, 2024
1 parent a625960 commit eca204e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/backend/tests/test_projects_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,44 @@ async def test_generate_project_files(db, client, project):
)
assert response.status_code == 200

async def test_update_project(client, admin_user, project):
"""Test update project metadata"""

updated_project_data = {
"project_info": {
"name": f"Updated Test Project {randint(1, 1000000)}",
"short_description": "updated short description",
"description": "updated description",
},
"xform_category": "buildings",
"hashtags": ["#FMTM"],
"outline_geojson": {
"coordinates": [
[
[85.317028828, 27.7052522097],
[85.317028828, 27.7041424888],
[85.318844411, 27.7041424888],
[85.318844411, 27.7052522097],
[85.317028828, 27.7052522097],
]
],
"type": "Polygon",
},
}

response = client.put(
f"/projects/{project.id}", json=updated_project_data
)

if response.status_code != 200:
log.error(response.json())
assert response.status_code == 200

response_data = response.json()
# Assert that project_info in response_data matches updated_project_data
assert response_data["project_info"]["name"] == updated_project_data["project_info"]["name"]
assert response_data["project_info"]["short_description"] == updated_project_data["project_info"]["short_description"]
assert response_data["project_info"]["description"] == updated_project_data["project_info"]["description"]

if __name__ == "__main__":
"""Main func if file invoked directly."""
Expand Down

0 comments on commit eca204e

Please sign in to comment.