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

Rework test suite base class #181

Merged
merged 14 commits into from
Jul 14, 2020
Merged

Rework test suite base class #181

merged 14 commits into from
Jul 14, 2020

Conversation

jomey
Copy link
Collaborator

@jomey jomey commented Jul 10, 2020

Sneaked quite some test structure changes into here and this should set a good foundation for the suite going forward.

Significant change is two fold:

  1. Rework the SMRFTestCase base class to use more methods and properties to enable easier overwrite for different config setups. This also added a method to copy the base config to ensure the initial copy will not be changed.
  2. Moved the two sample data basins into a basins folder. This separates test data from actual test logic.

@jomey jomey requested a review from scotthavens July 10, 2020 17:00
Copy link
Contributor

@scotthavens scotthavens left a comment

Choose a reason for hiding this comment

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

Looking good, a few copy and paste issues but it's a lot cleaner.

smrf/tests/output/test_output_variables.py Show resolved Hide resolved
smrf/tests/smrf_test_case.py Show resolved Hide resolved
smrf/tests/smrf_test_case.py Outdated Show resolved Hide resolved
smrf/tests/smrf_test_case_lakes.py Outdated Show resolved Hide resolved
smrf/tests/test_configurations.py Show resolved Hide resolved
smrf/tests/test_data_gridded.py Outdated Show resolved Hide resolved
smrf/tests/test_lakes_wind_ninja.py Outdated Show resolved Hide resolved
smrf/tests/test_lakes_wind_ninja.py Outdated Show resolved Hide resolved
Ensure that the verified test variables are not changed by tests and
return a copy of the frozen set.
Sweeping rework of the SMRFTestCase class, breaking the setUpClass into
chunks to enable overwriting of inheriting classes. Also adds a new
method to copy the SMRF wide base config and adapt for specific cases.
Change tests to use the configured output file from the .ini instead of
manually mapping that again.
There were two configs for RME test data and only the one under the main
test folder was used. Replace the existing one with the base. Brings it
in line with Lakes setup.
Start a 'basin' folder under the tests that holds the test data for
different basins. This also adds the `basin_dir` property to the
SMRFTestCase class.
Make the gold dir a property on the test case. This voids the need to
pass in the gold and comparison file, where only the path are different.
os.path.join(self.gold, 'air_temp.nc'),
os.path.join(self.output, 'air_temp.nc')
)
self.compare_netcdf_files('air_temp.nc')
Copy link
Contributor

Choose a reason for hiding this comment

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

Clean!

Declare threading config on the base class for use in inheriting test
setups to avoid threading debug adventures.
Everything was commented out.
@jomey jomey requested a review from scotthavens July 14, 2020 19:33
@jomey
Copy link
Collaborator Author

jomey commented Jul 14, 2020

Did some updates after resolving all the merge conflicts with latest master. Mostly organization.

'threading': True,
'max_queue': 1,
'time_out': 5
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Central config for test with threading

s = SMRF(self.base_config)
@staticmethod
def get_variables(config):
s = SMRF(config)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Think there was a bug here, where the passed in config was not used and the base without threading instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was attempting to run it not threaded first then threaded to see if any of the variables changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should we keep the test or nuke this class?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know, I'm on the fence. It's useful in the sense it makes us aware of what is in the queue. But it's a lot of extra code for that check.

Or can we move the assert_thread_variables here for a quick 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.

That's sound like a perfect place for it.

Copy link
Contributor

@scotthavens scotthavens left a comment

Choose a reason for hiding this comment

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

Nice to have the threading config centralized. Just removed a thread variable from the queue and the tests failed on the length count!

"""
Test for all defined BASE_THREAD_VARIABLES, not accounting for config
dependent additions.
"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is what I came up with

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good

"""
Test for all defined BASE_THREAD_VARIABLES, not accounting for config
dependent additions.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good

@jomey jomey merged commit b12a27b into master Jul 14, 2020
@jomey jomey deleted the tests/base_class branch July 14, 2020 21:59
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.

2 participants