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

Fixed software configuration commented out test #366

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/cript/nodes/subobjects/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,16 @@ class JsonAttributes(UUIDBaseNode.JsonAttributes):

def __init__(self, key: str, type: str, parameter: Optional[List[Parameter]] = None, citation: Optional[List[Citation]] = None, **kwargs): # ignored
"""
create algorithm sub-object
Create algorithm sub-object

Parameters
----------
key : str
algorithm key must come from [CRIPT controlled vocabulary]()
algorithm key must come from
[CRIPT controlled vocabulary](https://app.criptapp.org/vocab/algorithm_key)
type : str
algorithm type must come from [CRIPT controlled vocabulary]()
algorithm type must come from
[CRIPT controlled vocabulary](https://app.criptapp.org/vocab/algorithm_type)
parameter : List[Parameter], optional
parameter sub-object, by default None
citation : List[Citation], optional
Expand Down Expand Up @@ -134,7 +136,8 @@ def key(self, new_key: str) -> None:
"""
set the algorithm key

> Algorithm key must come from [CRIPT Controlled Vocabulary]()
> Algorithm key must come from
[CRIPT Controlled Vocabulary](https://app.criptapp.org/vocab/algorithm_key)

Parameters
----------
Expand All @@ -149,7 +152,8 @@ def type(self) -> str:
"""
Algorithm type

> Algorithm type must come from [CRIPT controlled vocabulary]()
> Algorithm type must come from
[CRIPT controlled vocabulary](https://app.criptapp.org/vocab/algorithm_type)

Examples
--------
Expand Down
46 changes: 26 additions & 20 deletions tests/nodes/subobjects/test_software_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,32 @@ def test_json(complex_software_configuration_node, complex_software_configuratio
assert strip_uid_from_dict(json.loads(sc2.json)) == strip_uid_from_dict(json.loads(sc.json))


def test_setter_getter(complex_software_configuration_node, simple_algorithm_node, complex_citation_node):
sc2 = complex_software_configuration_node
software2 = sc2.software
sc2.software = software2
assert sc2.software is software2

# assert len(sc2.algorithm) == 1
# al2 = simple_algorithm_node
# print(sc2.get_json(indent=2,sortkeys=False).json)
# print(al2.get_json(indent=2,sortkeys=False).json)
# sc2.algorithm += [al2]
# assert sc2.algorithm[1] is al2

sc2.notes = "my new fancy notes"
assert sc2.notes == "my new fancy notes"

# cit2 = complex_citation_node
# assert len(sc2.citation) == 1
# sc2.citation += [cit2]
# assert sc2.citation[1] == cit2
def test_setter_getter(simple_software_configuration, simple_algorithm_node, complex_citation_node):
"""
test setters and getters for `SoftwareConfiguration` and be sure it works fine
also test that the node can be set and also reset
"""
new_notes: str = "my new notes"

# use setters
simple_software_configuration.algorithm = [simple_algorithm_node]
simple_software_configuration.citation = [complex_citation_node]
simple_software_configuration.notes = new_notes

# assert getters and setters are same
assert simple_software_configuration.algorithm == [simple_algorithm_node]
assert simple_software_configuration.citation == [complex_citation_node]
assert simple_software_configuration.notes == new_notes

# remove optional attributes
simple_software_configuration.algorithm = []
simple_software_configuration.citation = []
simple_software_configuration.notes = ""

# assert that optional attributes have been removed from data node
assert simple_software_configuration.algorithm == []
assert simple_software_configuration.citation == []
assert simple_software_configuration.notes == ""


def test_integration_software_configuration(cript_api, simple_project_node, simple_collection_node, simple_experiment_node, simple_computation_node, simple_software_configuration):
Expand Down