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

TST: Clean warnings #1129

Merged
merged 22 commits into from
Jul 13, 2023
Merged

TST: Clean warnings #1129

merged 22 commits into from
Jul 13, 2023

Conversation

aburrell
Copy link
Member

@aburrell aburrell commented Jul 5, 2023

Description

Addresses #1009 by adding a general test triggered by an optional testing variable to the standard set of Instrument tests. Adapted the clean method in the test instruments to run all potential iterations of the allowed behaviour, which includes:

  • logging messages
  • warnings
  • errors
  • changing the clean level

Updated the documentation to describe how this testing should be done.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Added unit tests. Also added this line to ace_epam.py in pysatSpaceWeather and ran the local unit tests.

# Set clean warning tests
_clean_warn = {'': {'': {'dusty': [('logger', 'WARN',
                         "unused clean level 'dusty', reverting to 'clean'",
                         'clean')]}}}

Test Configuration:

Checklist:

  • Make sure you are merging into the develop (not main) branch
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • Add a note to CHANGELOG.md, summarizing the changes

If this is a release PR, replace the first item of the above checklist with the release
checklist on the wiki: https://github.com/pysat/pysat/wiki/Checklist-for-Release

aburrell added 6 commits July 5, 2023 16:23
Added a test for logging messages, warnings, and errors that may occur in Instrument `clean` methods.  Also tests to see if the clean level has been reset correctly.
Added level resetting, logging messages, warnings, and errors as potential outputs to the clean method for test instruments.  Also added a unit test for each of these elements.
Updated the new instrument instructions for the clean method and `_clean_warn` test variable.
Updated the changelog with a description of this pull request.
Updated the reference style in the docs.
Fixing bug in reference format.
@aburrell aburrell added this to the 3.2.0 Release milestone Jul 5, 2023
@aburrell aburrell linked an issue Jul 5, 2023 that may be closed by this pull request
@aburrell aburrell requested a review from rstoneback July 5, 2023 20:45
Fixed logic in clean method, allowing key search only if input is a dict.
@aburrell
Copy link
Member Author

aburrell commented Jul 6, 2023

_clean_warn needs inst_id and tag incorporated.

Updated example for `_clean_warn` in docs to include inst_id and tag.
aburrell and others added 2 commits July 6, 2023 11:47
Removed lines that cannot be reached, as the clean method doesn't run if the clean level is 'none'.
Updated the `_clean_warn` format to accept a list of tuples.
Moved the discussion of the new clean_warn test attribute to its own section and updated the reference.
Added a missing quotation mark.
@aburrell aburrell requested a review from jklenzing July 6, 2023 17:29
aburrell added 4 commits July 6, 2023 16:33
Fixed the dict access for the expected clean warnings.
Ensure the strict time flag is not raising a ValueError when testing the clean warning messages.
Cannot assess other warnings when an error is raised, only test multiple non-fatal warnings.
Improved the logging error message in the clean warning test to be more useful.
Copy link
Member

@jklenzing jklenzing left a comment

Choose a reason for hiding this comment

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

Looks good. I would suggest restructuring so that tests where nothing is run are skipped to be consistent with similar tests elsewhere.

Fixed spelling and line length in the docs.
Improved the clean warning test by:
- Creating a function for testing/setting the strict time flag,
- Removing 'none' from the clean level parametrization,
- Fixing the docstrings,
- Adding more comments, and
- Adding pytest skip statements.
@aburrell aburrell requested a review from jklenzing July 10, 2023 19:50
@aburrell
Copy link
Member Author

The decrease in coverage is consistent with tests not being skipped and edge cases for ecosystem packages not being triggered.

Copy link
Member

@jklenzing jklenzing left a comment

Choose a reason for hiding this comment

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

The generalized function as written will cause a change in test_load

Fixed comments to be accurate.

Co-authored-by: Jeff Klenzing <[email protected]>
@aburrell aburrell requested a review from jklenzing July 11, 2023 16:25
Allow the strict flag function to run with or without the clean method.
@aburrell aburrell requested review from jklenzing July 11, 2023 18:09
aburrell and others added 2 commits July 12, 2023 13:26
Rename the test function as per discussion.

Co-authored-by: Jeff Klenzing <[email protected]>
@jklenzing jklenzing mentioned this pull request Jul 13, 2023
11 tasks
@aburrell aburrell merged commit 09673ae into develop Jul 13, 2023
@aburrell aburrell deleted the clean_warnings branch July 13, 2023 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Standards for Instruments without cleaning.
2 participants