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 unit tests for gpm_api.io #8

Merged
merged 39 commits into from
Sep 6, 2023
Merged

Conversation

evanjt
Copy link
Collaborator

@evanjt evanjt commented Jul 19, 2023

Prework

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Documentation
  • Tutorial
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe: Tests

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and communicate accordingly:

The PR fulfills these requirements:

  • It's submitted to the branch named as follow :
    • Fix a bug: bugfix-<some_key>-<word>
    • Improve the doc: doc-<some_key>-<word>
    • Improve a tutorial tutorial-<some_key>-<word>
    • Add a new feature: feature-<some_key>-<word>
    • Refactor some code: refactor-<some_key>-<word>
    • Optimize some code: optimize-<some_key>-<word>
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)
  • Don't forget to link PR to issue if you are solving one.
  • All tests are passing.
  • New/updated tests are included

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

Related GitHub issues and pull requests

  • Ref: #

Summary

Please explain the purpose and scope of your contribution.

Incorporate tests for gpm_api.io

@evanjt evanjt requested review from sphamba and ghiggi July 19, 2023 17:17
@evanjt evanjt self-assigned this Jul 19, 2023
Copy link
Owner

@ghiggi ghiggi left a comment

Choose a reason for hiding this comment

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

The tests looks great. I have just a couple of comments ;)

gpm_api/tests/io/test_checks.py Outdated Show resolved Hide resolved
gpm_api/tests/io/test_checks.py Outdated Show resolved Hide resolved
gpm_api/tests/io/test_checks.py Outdated Show resolved Hide resolved
gpm_api/tests/io/test_checks.py Outdated Show resolved Hide resolved
gpm_api/tests/io/test_checks.py Show resolved Hide resolved
gpm_api/tests/io/test_checks.py Outdated Show resolved Hide resolved
gpm_api/tests/io/test_checks.py Outdated Show resolved Hide resolved
…uture use, allow check_time to fix incoming str and np objects into check_date()
Copy link
Collaborator

@sphamba sphamba left a comment

Choose a reason for hiding this comment

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

@evanjt Check why tests do not pass CI (Python 3.8 apparently)

gpm_api/tests/io/test_checks.py Outdated Show resolved Hide resolved
gpm_api/tests/io/test_checks.py Outdated Show resolved Hide resolved
gpm_api/io/checks.py Outdated Show resolved Hide resolved
…s to not replace host (arthurhouftps.pps.eosdis.nasa.gov -> arthurhouftp.pps.eosdis.nasa.gov)
@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Merging #8 (9bac278) into main (9e0212e) will decrease coverage by 0.16%.
Report is 96 commits behind head on main.
The diff coverage is 0.00%.

❗ Current head 9bac278 differs from pull request most recent head 03d7578. Consider uploading reports for the commit 03d7578 to get more accurate results

@@           Coverage Diff            @@
##            main      #8      +/-   ##
========================================
- Coverage   0.15%   0.00%   -0.16%     
========================================
  Files         41      40       -1     
  Lines       3300    3313      +13     
========================================
- Hits           5       0       -5     
- Misses      3295    3313      +18     
Files Changed Coverage Δ
gpm_api/io/checks.py 0.00% <0.00%> (ø)
gpm_api/io/directories.py 0.00% <ø> (ø)
gpm_api/io/download.py 0.00% <0.00%> (ø)
gpm_api/tests/conftest.py 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

@evanjt
Copy link
Collaborator Author

evanjt commented Jul 24, 2023

@evanjt Check why tests do not pass CI (Python 3.8 apparently)

@sphamba They are not passing as type hints became supported with standard objects rather than needing to import them from the typing library in 3.9 https://peps.python.org/pep-0585/.

We can consider importing annotations from __future__ https://stackoverflow.com/questions/63939138/is-there-a-way-to-use-python-3-9-type-hinting-in-its-previous-versions in the Python 3.8 tests somehow, what do you think?

@evanjt evanjt requested a review from sphamba July 24, 2023 13:36
@sphamba
Copy link
Collaborator

sphamba commented Jul 24, 2023

@evanjt Check why tests do not pass CI (Python 3.8 apparently)

@sphamba They are not passing as type hints became supported with standard objects rather than needing to import them from the typing library in 3.9 https://peps.python.org/pep-0585/.

We can consider importing annotations from __future__ https://stackoverflow.com/questions/63939138/is-there-a-way-to-use-python-3-9-type-hinting-in-its-previous-versions in the Python 3.8 tests somehow, what do you think?

@ghiggi We could switch to the Python 3.8 style of type hinting (with from typing import ...) as in DisdroDB. Is that ok for you?

@sphamba sphamba requested review from sphamba and removed request for sphamba July 24, 2023 14:55
@ghiggi
Copy link
Owner

ghiggi commented Jul 24, 2023

Or can we drop support for python 3.8 @sphamba @evanjt ?
It may be easier ....

@sphamba
Copy link
Collaborator

sphamba commented Jul 25, 2023

Or can we drop support for python 3.8 @sphamba @evanjt ? It may be easier ....

I don't know
Since we instruct users how to setup a virtual environment, we could very well set Python 3.9 as a minimum version, imo

@evanjt
Copy link
Collaborator Author

evanjt commented Jul 25, 2023

I think changing the type hints to those compatible with 3.8 is a good balance between improving typing for future versions and supporting older Python installations, especially after seeing the amount of people using 3.8 still. If we consider adding them to the library, then the application will not run at all for <= 3.8 versions.

@evanjt evanjt marked this pull request as ready for review August 18, 2023 00:48
@evanjt evanjt requested a review from sphamba August 18, 2023 00:50
@evanjt
Copy link
Collaborator Author

evanjt commented Aug 18, 2023

At this stage, I believe most of the testing is done in this module without spending a considerable amount of time mocking requests and responses

gpm_api/tests/io/test_filter.py Outdated Show resolved Hide resolved
…lter_by_time(), modify the default None behaviour to choose utcnow() instead of now() to avoid timezone related issues
Copy link
Owner

@ghiggi ghiggi left a comment

Choose a reason for hiding this comment

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

I reviewed a first part

gpm_api/io/checks.py Outdated Show resolved Hide resolved
gpm_api/io/checks.py Outdated Show resolved Hide resolved
gpm_api/io/download.py Show resolved Hide resolved
gpm_api/tests/conftest.py Show resolved Hide resolved
gpm_api/tests/conftest.py Show resolved Hide resolved
gpm_api/tests/io/test_checks.py Outdated Show resolved Hide resolved
gpm_api/tests/io/test_checks.py Show resolved Hide resolved
gpm_api/tests/io/test_checks.py Show resolved Hide resolved
gpm_api/tests/io/test_data_integrity.py Show resolved Hide resolved
gpm_api/tests/io/test_directories.py Show resolved Hide resolved
Copy link
Owner

@ghiggi ghiggi left a comment

Choose a reason for hiding this comment

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

I finished to review the rest of the code. @evanjt we can have a Zoom in the coming days to clarify what remains to be done ;)
Have a nice week !

gpm_api/tests/io/test_download.py Outdated Show resolved Hide resolved
) -> None:
"""Test check_download_status function"""

for product in products:
Copy link
Owner

Choose a reason for hiding this comment

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

Here we don't need to loop over products. product is an argument of _check_download_status just to display an informative message, but does not condition execution. So define a dummy product string within the test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the function changes in the future to be restricted to a product for whichever reason, should we not keep the loop in to check all possible products work with it as defined in the internal product list?

If it's a case of simplifying the test routine, I'm happy to simplify it, specifying a random string here would restrict the tests to a static constant outside of the scope of the realistic product list, perhaps we could just use the first element of the list?

Copy link
Owner

Choose a reason for hiding this comment

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

Ok I agree. In the end I guess does not take lot of time to execute this test.

gpm_api/tests/io/test_download.py Show resolved Hide resolved
gpm_api/tests/io/test_filter.py Show resolved Hide resolved
gpm_api/tests/io/test_filter.py Outdated Show resolved Hide resolved
gpm_api/tests/io/test_disk.py Show resolved Hide resolved
@regislon
Copy link
Collaborator

regislon commented Sep 5, 2023

Dear @ghiggi ,

This pull request has been open for more than one month. Can we close it without further changes and create new issues to address any important remarks you may have for the rest of the project? Keeping a pull request open for such a long time is not ideal in terms of traceability.

Furthermore, the time spent on this task is at the expense of others. Could we be picky at the end of the project ?

Repository owner deleted a comment from evanjt Sep 5, 2023
@ghiggi
Copy link
Owner

ghiggi commented Sep 5, 2023

Hey @regislon and @evanjt !
I was expecting @evanjt to address some of the issues ... I didn't receive any message from him.
As it is, some of the changes to the codebase (datetime modified in ms instead of s) break the API.
I listed tasks that can be postponed (resolving the conversations above) into: #13
I recommend @evanjt to look at the 5-6 remaining unresolved conversations in all my reviews and address those to merge the PR. It should take max 1 hour... are just small fixes mainly related to dealing with the time objects!

@evanjt
Copy link
Collaborator Author

evanjt commented Sep 6, 2023

Hi @ghiggi thanks for the comments. I replied to some of your messages and made changes last week but not all of them as my time was limited. Furthermore, as I understood from our last meeting, you did not want more hours spent on this module, so with the time I had, I limited it to the ones that did not require additional modifications of the code base.

With respect to your latest comments, the issue with the microseconds to seconds was a misjudgement of mine through the threads in this PR earlier in July, and have corrected it, along with the other items you have noted.

@ghiggi ghiggi merged commit e39dc20 into ghiggi:main Sep 6, 2023
7 of 9 checks passed
@ghiggi
Copy link
Owner

ghiggi commented Sep 6, 2023

Thanks @evanjt for having done this annoying work. The PR is now merged :)
Cc @regislon

@ghiggi ghiggi deleted the add_io_tests branch September 6, 2023 13:50
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.

5 participants