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 the pontoon.insights module (#3015) #3079

Merged
merged 7 commits into from
Feb 15, 2024

Conversation

potat0
Copy link
Contributor

@potat0 potat0 commented Jan 28, 2024

Fix #3015.

This is my first contribution to this project. Let me know if there are any improvements I can do. 

  • Added tests for pontoon.insights module
  • Added test for calling the endpoint without arguments and no data
  • Added test with approved and rejected translations per month and assert that the translation quality percents match
  • Ran make test
    • image
    • image
    • image

Copy link
Collaborator

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

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

Nice work!

Only left a few comments to hopefully make the code slightly more manageable.

pontoon/insights/tests/test_views.py Outdated Show resolved Hide resolved
pontoon/insights/tests/test_views.py Outdated Show resolved Hide resolved
pontoon/insights/tests/test_views.py Outdated Show resolved Hide resolved
pontoon/insights/tests/test_views.py Outdated Show resolved Hide resolved
@potat0
Copy link
Contributor Author

potat0 commented Jan 30, 2024

Thank you for the review! I'll try to get around to making changes this weekend.

@potat0 potat0 requested a review from mathjazz February 3, 2024 18:40
@potat0
Copy link
Contributor Author

potat0 commented Feb 13, 2024

Hi @mathjazz , let me know if there are any additional changes you would like to see.

Copy link
Collaborator

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

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

Thanks for the update (and sorry for the slow response from my end!).

I only added a couple more comments.

Going forward, could you please just add commits with changes, rather than force-push? That way it'll be much easier to see what exactly has changed since the code has been looked at.

pontoon/test/fixtures/base.py Outdated Show resolved Hide resolved
pontoon/test/fixtures/base.py Outdated Show resolved Hide resolved
@potat0
Copy link
Contributor Author

potat0 commented Feb 14, 2024

Hi @mathjazz . No problem. Sorry for missing moving the fixtures from test_pretranslate.py. Hopefully I got everything this time. I'll use normal commits going forward instead of force pushes.

@mathjazz
Copy link
Collaborator

Thanks for the update!

Please see the failing tests.

@mathjazz
Copy link
Collaborator

Please note that the pytest is still failing - we just introduced caching that causes it:
7bdcacc#diff-78a0f2e1d3a0a671add455c921328565557bfd1c242000b244fb2a9677a696bcR10

@potat0
Copy link
Contributor Author

potat0 commented Feb 15, 2024

Thank you for pointing out the latest caching update. I was stumped why it was failing in ci/cd. After pulling and merging latest, I was able to reproduce the pytest failure occurring in the GitHub action. Clearing the cache prior to running the tests seems to fix it locally. I was looking into how to clear specific views out of the cache, but these solutions (https://stackoverflow.com/questions/2268417/expire-a-view-cache-in-django/2268583#2268583) are quite involved and could be brittle since they depend on the implementation within Django.

@mathjazz
Copy link
Collaborator

Thank you for pointing out the latest caching update. I was stumped why it was failing in ci/cd. After pulling and merging latest, I was able to reproduce the pytest failure occurring in the GitHub action. Clearing the cache prior to running the tests seems to fix it locally. I was looking into how to clear specific views out of the cache, but these solutions (https://stackoverflow.com/questions/2268417/expire-a-view-cache-in-django/2268583#2268583) are quite involved and could be brittle since they depend on the implementation within Django.

Nicely done!

Thank you for your contribution to Pontoon!

@mathjazz mathjazz merged commit 0afb7d7 into mozilla:main Feb 15, 2024
4 checks passed
ayanaar pushed a commit to ayanaar/pontoon that referenced this pull request Feb 23, 2024
mathjazz added a commit to mathjazz/pontoon that referenced this pull request Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add unit tests for the pontoon.insights module
2 participants