-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8cf7ee8
commit 6b23817
Showing
13 changed files
with
194 additions
and
137 deletions.
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
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 |
---|---|---|
@@ -1,40 +1,32 @@ | ||
from dewret.renderers.cwl import set_configuration, configuration | ||
|
||
|
||
def test_default_configuration(): | ||
"""Test the default configuration.""" | ||
# Set default configuration | ||
set_configuration({}) | ||
|
||
# Retrieve default settings | ||
|
||
assert configuration("allow_complex_types") is False | ||
assert configuration("factories_as_params") is False | ||
|
||
|
||
def test_custom_configuration(): | ||
"""Test setting and retrieving custom configuration.""" | ||
# Set custom configuration | ||
custom_config = { | ||
"allow_complex_types": True, | ||
"factories_as_params": True | ||
} | ||
custom_config = {"allow_complex_types": True, "factories_as_params": True} | ||
set_configuration(custom_config) | ||
|
||
# Retrieve custom settings | ||
|
||
assert configuration("allow_complex_types") is True | ||
assert configuration("factories_as_params") is True | ||
|
||
|
||
def test_unknown_configuration_key(): | ||
"""Test retrieving an unknown configuration key.""" | ||
# Set some configuration | ||
set_configuration({"allow_complex_types": True}) | ||
|
||
# Retrieve known key | ||
|
||
assert configuration("allow_complex_types") is True | ||
|
||
# Retrieve unknown key | ||
|
||
try: | ||
configuration("unknown_key") | ||
except KeyError as e: | ||
assert str(e) == "'Unknown configuration settings.'" | ||
else: | ||
raise AssertionError("Expected KeyError not raised.") | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,49 @@ | ||
from dewret.renderers.cwl import ReferenceDefinition | ||
|
||
|
||
class MockReference: | ||
"""Mock class to simulate a `Reference` object.""" | ||
|
||
def __init__(self, name: str): | ||
self.name = name | ||
|
||
|
||
def test_reference_definition_from_reference(): | ||
"""Test the `from_reference` class method.""" | ||
ref = MockReference(name="test_step") | ||
|
||
# Create a ReferenceDefinition from a Reference | ||
ref_def = ReferenceDefinition.from_reference(ref) | ||
|
||
# Assert the source is correctly set | ||
assert ref_def.source == "test_step" | ||
|
||
|
||
def test_reference_definition_render(): | ||
"""Test the `render` method.""" | ||
# Create a ReferenceDefinition instance | ||
ref_def = ReferenceDefinition(source="test_step") | ||
|
||
# Render the instance to a dict | ||
rendered = ref_def.render() | ||
|
||
# Expected rendered dict | ||
expected = {"source": "test_step"} | ||
|
||
# Assert the rendered dict is as expected | ||
assert rendered == expected | ||
|
||
|
||
def test_reference_definition_render_empty_source(): | ||
"""Test the `render` method with an empty source.""" | ||
# Create a ReferenceDefinition instance with an empty source | ||
ref_def = ReferenceDefinition(source="") | ||
|
||
# Render the instance to a dict | ||
rendered = ref_def.render() | ||
|
||
# Expected rendered dict | ||
expected = {"source": ""} | ||
|
||
# Assert the rendered dict is as expected | ||
assert rendered == expected | ||
assert rendered == expected |
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
Oops, something went wrong.