Skip to content
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

Add tests for submission routes #1917

Merged
merged 9 commits into from
Nov 28, 2024

Conversation

Anuj-Gupta4
Copy link
Contributor

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

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

Related Issue

Example: Resolves #1913

Describe this PR

A fixture for submission has been created and some tests have been added for submission routes.

Checklist before requesting a review

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.

I love that this adds another test, so going to approve after minor fixes πŸ‘

There's definitely more scope to test the different submission download types after, like CSV and geojson (this is in a different endpoint I think).

But I just wanted to comment that using basic auth via requests auth= isn't great. I'm surprised that ODK Central accepts this & support could possibly be removed in the future. In osm-fieldwork we have wrappers for the Central API (as does pyodk). Both of those libraries handle Central authentication via the sessions API (request a session token, then use the token to authenticate).

It's still a good PR though! πŸ’«

src/backend/tests/conftest.py Outdated Show resolved Hide resolved
src/backend/tests/conftest.py Outdated Show resolved Hide resolved
@Anuj-Gupta4
Copy link
Contributor Author

Anuj-Gupta4 commented Nov 26, 2024

@spwoodcock
Should I add more tests for submission routes?

I wonder if i should simply make another api call to replace the basic auth with session authentication using:
https://docs.getodk.org/central-api-authentication/#using-the-session

@spwoodcock
Copy link
Member

No need for that if this approach works πŸ˜„

I think it would be more valuable adding pyodk as a dependency in FMTM, as it might be useful elsewhere anyway:

uv add pyodk

The submission could be created with the pyodk client, then more tests written for json CSV and geojson downloads =)

I'll leave you to assess how much time this may take though and if it's worth it. Requirements relates to Tokha could be addressed instead if this will take a long time πŸ‘ Either way is fine!

@Anuj-Gupta4
Copy link
Contributor Author

I haven't included the .pyodk_config.toml file in tests directory.

@spwoodcock
Copy link
Member

As the credentials are only used for testing, it's ok to commit that file. I think we need it for the tests to work (pyodk doesn't accept environment variables unfortunately πŸ₯²)

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 excellent, well done!

Two tiny changes and all good to merge

src/backend/tests/conftest.py Outdated Show resolved Hide resolved
@spwoodcock
Copy link
Member

Sorry Anuj! I didn't mean the dev server credentials!

The credentials you can use are for the locally installed version of ODK Central, which always has user [email protected] and password Password1234. The URL is https://proxy (which resolves to the proxy container, and then forwards traffic to the ODK Central container over HTTPS)

@Anuj-Gupta4
Copy link
Contributor Author

Oops my bad.

@spwoodcock spwoodcock changed the title Test/submission routes Add tests for submission routes Nov 28, 2024
@spwoodcock spwoodcock merged commit d5bae01 into hotosm:development Nov 28, 2024
4 of 5 checks passed
@Anuj-Gupta4 Anuj-Gupta4 deleted the test/submission-routes branch November 28, 2024 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to backend code tests Related to automated code tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add functional pytest Test cases for submission module
2 participants