Skip to content

Commit

Permalink
test(backend): update project endpoint (#1557)
Browse files Browse the repository at this point in the history
* feat: added test for update project routes

* fix: applied git pre-commit hooks
  • Loading branch information
azharcodeit authored Jun 11, 2024
1 parent 35d58d2 commit c7a681b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ repos:
hooks:
- id: shellcheck
files: ^(?!.*(?:^|/)contrib(?:/|$)).*$
args: ["-x", "--exclude=SC2317,SC2188,SC2143"]
args: ["-x", "--exclude=SC2317,SC2188,SC2143,SC2086,SC1091"]

# Lint: Markdown
- repo: https://github.com/igorshubovych/markdownlint-cli
Expand Down
46 changes: 46 additions & 0 deletions src/backend/tests/test_projects_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,52 @@ 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."""
pytest.main()

0 comments on commit c7a681b

Please sign in to comment.