Skip to content

Add some tests for project and task routes #2346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2025

Conversation

Anuj-Gupta4
Copy link
Collaborator

What type of PR is this? (check all applicable)

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation
  • πŸ§‘β€πŸ’» Refactor
  • βœ… Test
  • πŸ€– Build or CI
  • ❓ Other (please specify)

Related Issue

Describe this PR

Tests to:

  • read project
  • update project form
  • download project form
  • get contributors
  • add new pm and get project user
  • create entity
  • download project boundary
  • download task boundary
  • create geometry log
  • read geometry log
  • delete geometry log
  • read tasks
  • get specific task
  • more task events
  • get task activity

@Anuj-Gupta4 Anuj-Gupta4 requested a review from Sujanadh April 4, 2025 10:07
@github-actions github-actions bot added enhancement New feature or request backend Related to backend code tests Related to automated code tests labels Apr 4, 2025
@Anuj-Gupta4 Anuj-Gupta4 marked this pull request as ready for review April 6, 2025 11:47
@@ -817,7 +817,7 @@ async def update_project_form(
"project_id": project.id,
},
)
db.commit()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, but I'm not sure we really need db.commit() anywhere in the codebase to be honest:

  • When an endpoint is called a transaction is started via a context manager
  • Before the cursor / transaction is closed, the SQL is executed automatically

xls_file = BytesIO(updated_xls_content)
xls_file.name = "form.xlsx"

with patch(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this patch is good, we do run the entire stack for these tests (db, api, odk central), so you could get the actual response rather than doing a patch πŸ‘


contributor = data[0]
assert contributor["user"] == admin_user.username
assert contributor["contributions"] == 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to have this as >2 or something, as this could break in future if we added more tests that create task events

Copy link
Member

@spwoodcock spwoodcock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice work - well done πŸ˜„

@spwoodcock spwoodcock merged commit 4ad42fa into development Apr 9, 2025
5 checks passed
@spwoodcock spwoodcock deleted the feat/backend/test-cases branch April 9, 2025 15:20
@spwoodcock
Copy link
Member

Test coverage increase 68% --> 72% πŸ™Œ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to backend code enhancement New feature or request tests Related to automated code tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants