-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/dei 24 tests for parser #7
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2f07b71
get tests to 100%
CindyvdVries c6bb380
add missing tests
CindyvdVries 45d3965
flaking
CindyvdVries f56aa92
add test nc files
CindyvdVries 5dbf81d
update review feedback, remove print statement and add description pa…
CindyvdVries e98c014
update review feedback, add check on type for multipliers
CindyvdVries fc6d804
Update parser_multiply_rule.py
CindyvdVries File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,3 +131,4 @@ dmypy.json | |
# test files | ||
input_file.yaml | ||
**/*.nc | ||
!tests/**/*.nc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/data/entities/test_dataset_data_data/FlowFM_net_incorrect.nc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test incorrect nc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
""" | ||
Tests for ModelDataBuilder class | ||
""" | ||
|
||
import pytest | ||
|
||
from decoimpact.data.api.i_model_data import IModelData | ||
from decoimpact.data.entities.model_data_builder import ModelDataBuilder | ||
|
||
contents = dict( | ||
{ | ||
"input-data": [ | ||
{"dataset": {"filename": "test", "variabel_mapping": {"foo": "bar"}}} | ||
], | ||
"rules": [ | ||
{ | ||
"multiply_rule": { | ||
"name": "testrule", | ||
"description": "testdescription", | ||
"multipliers": [1, 2.0], | ||
"input_variable": "testin", | ||
"output_variable": "testout", | ||
} | ||
} | ||
], | ||
} | ||
) | ||
|
||
|
||
def test_model_data_builder_parse_dict_to_model_data(): | ||
"""The ModelDataBuilder should parse the provided dictionary | ||
to a IModelData object""" | ||
|
||
# Act | ||
data = ModelDataBuilder() | ||
|
||
parsed_data = data.parse_yaml_data(contents) | ||
assert isinstance(parsed_data, IModelData) | ||
|
||
|
||
def test_model_data_builder_gives_error_when_rule_not_defined(): | ||
"""The ModelDataBuilder should parse the provided dictionary | ||
to a IModelData object""" | ||
|
||
# Act | ||
data = ModelDataBuilder() | ||
contents["rules"] = [{"wrong_rule": "test"}] | ||
|
||
with pytest.raises(KeyError) as exc_info: | ||
data.parse_yaml_data(contents) | ||
|
||
exception_raised = exc_info.value | ||
|
||
# Assert | ||
exc = exception_raised.args[0] | ||
assert exc.endswith(f"No parser for wrong_rule") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Tests for MultiplyRuleData class | ||
""" | ||
|
||
from decoimpact.data.api.i_rule_data import IRuleData | ||
from decoimpact.data.entities.multiply_rule_data import MultiplyRuleData | ||
|
||
|
||
def test_multiply_rule_data_creation_logic(): | ||
"""The MultiplyRuleData should parse the provided dictionary | ||
to correctly initialize itself during creation""" | ||
|
||
# Act | ||
data = MultiplyRuleData("test_name", [1.0, 2.0], "input", "output", "description") | ||
|
||
# Assert | ||
|
||
assert isinstance(data, IRuleData) | ||
assert data.input_variable == "input" | ||
assert data.multipliers == [1.0, 2.0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print statement can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add a description for the parameter ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check, added it. Have now on multiple locations a default for the description.
print statement removed