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

Refactors trnsys tests #79

Merged
merged 37 commits into from
Apr 22, 2020

Conversation

louisleroy5
Copy link
Collaborator

Refactors tests to improve coverage and for tests to run faster

@samuelduchesne
Copy link
Owner

Addresses issue #68

@samuelduchesne samuelduchesne linked an issue Apr 17, 2020 that may be closed by this pull request
Makes sure load_idf_file_and_clean_names() returns unique names and an IDF object
Makes sure csv file with schedules exists and that schedules are written in lines
Makes sure version and building information written in lines
Makes sure materials (material, AirGap, NoMass, etc.) are written in lines
Makes sure relative coords converted to absolute ones
Makes sure path to T3D file exists
Value of conditioning in REGIME section has to be the name of the conditioning system previously written in Conditioning section (must be a string, not a list or half-string etc.)
Makes sure infiltration, internal gains and conditioning are written in b18_lines
@louisleroy5 louisleroy5 added the enhancement Includes code that add's enhancements to existing archetypal functionalities label Apr 17, 2020

idf = add_object_and_run_ep(ep_version, idf_file, weather_file, outputs)

assert type(idf) == ar.idfclass.IDF
Copy link
Owner

Choose a reason for hiding this comment

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

use assert isinstance(idf, ar.idfclass.IDF)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -425,6 +414,23 @@ def convert_idf_to_trnbuild(
return return_path


def add_object_and_run_ep(ep_version, idf_file, weather_file, outputs):
Copy link
Owner

Choose a reason for hiding this comment

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

Why did you wrap the run_eplus method in this new add_object_and_run_ep()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To have better coverage for trnsys.py

tests/test_trnsys.py Outdated Show resolved Hide resolved
@samuelduchesne
Copy link
Owner

samuelduchesne commented Apr 18, 2020 via email

@louisleroy5
Copy link
Collaborator Author

louisleroy5 commented Apr 18, 2020 via email

@samuelduchesne
Copy link
Owner

samuelduchesne commented Apr 18, 2020 via email

No need to wrap a function in an other one if it does not bring any new functionality
Copy link
Owner

@samuelduchesne samuelduchesne left a comment

Choose a reason for hiding this comment

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

@louisleroy5 , this is what I mean. There is no additional functionality to wrap a function inside another one. In other words, calling add_object_and_run_ep is exactly the same as calling run_eplus with the same arguments

@louisleroy5
Copy link
Collaborator Author

louisleroy5 commented Apr 18, 2020 via email

@samuelduchesne samuelduchesne self-requested a review April 18, 2020 21:17
) = _assert_files(
idf_file, weather_file, window_lib, output_folder, trnsidf_exe, template
)
except:
Copy link
Owner

Choose a reason for hiding this comment

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

This except statement is too general. try, except what? KeyError? ValueError?

Copy link
Owner

Choose a reason for hiding this comment

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

Even better, put the _assert_files under a with pytest.raises(Exception): and get rid of the try, except clause

Make sure to replace "Exception" by the actual exception your method raises. This way, pytest will be happy and display the correct information

Copy link
Owner

Choose a reason for hiding this comment

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

samuelduchesne
samuelduchesne previously approved these changes Apr 20, 2020
Copy link
Owner

@samuelduchesne samuelduchesne left a comment

Choose a reason for hiding this comment

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

A lot cleaner!

@samuelduchesne samuelduchesne dismissed their stale review April 20, 2020 15:14

Actually, the Windows build is failing

@samuelduchesne samuelduchesne merged commit 218675a into samuelduchesne:develop Apr 22, 2020
@louisleroy5 louisleroy5 deleted the feature/TestTrnsys branch April 22, 2020 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Includes code that add's enhancements to existing archetypal functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI tests need to be much quicker
2 participants