diff --git a/tests/nodes/primary_nodes/test_collection.py b/tests/nodes/primary_nodes/test_collection.py index 0925729fe..9f6726bcf 100644 --- a/tests/nodes/primary_nodes/test_collection.py +++ b/tests/nodes/primary_nodes/test_collection.py @@ -37,14 +37,9 @@ def test_create_complex_collection(simple_experiment_node, simple_inventory_node """ my_collection_name = "my complex collection name" my_cript_doi = "10.1038/1781168a0" + my_collection_notes = "test_create_complex_collection notes" - my_collection = cript.Collection( - name=my_collection_name, - experiment=[simple_experiment_node], - inventory=[simple_inventory_node], - doi=my_cript_doi, - citation=[complex_citation_node], - ) + my_collection = cript.Collection(name=my_collection_name, experiment=[simple_experiment_node], inventory=[simple_inventory_node], doi=my_cript_doi, citation=[complex_citation_node], notes=my_collection_notes) # assertions assert isinstance(my_collection, cript.Collection) @@ -53,6 +48,7 @@ def test_create_complex_collection(simple_experiment_node, simple_inventory_node assert my_collection.inventory == [simple_inventory_node] assert my_collection.doi == my_cript_doi assert my_collection.citation == [complex_citation_node] + assert my_collection.notes == my_collection_notes def test_collection_getters_and_setters(simple_experiment_node, simple_inventory_node, complex_citation_node) -> None: @@ -69,6 +65,7 @@ def test_collection_getters_and_setters(simple_experiment_node, simple_inventory new_collection_name = "my new collection name" new_cript_doi = "my new cript doi" + new_collection_notes = "my collection getters and setters notes" # set Collection attributes my_collection.name = new_collection_name @@ -76,6 +73,7 @@ def test_collection_getters_and_setters(simple_experiment_node, simple_inventory my_collection.inventory = [simple_inventory_node] my_collection.doi = new_cript_doi my_collection.citation = [complex_citation_node] + my_collection.notes = new_collection_notes # assert getters and setters are the same assert isinstance(my_collection, cript.Collection) @@ -84,12 +82,14 @@ def test_collection_getters_and_setters(simple_experiment_node, simple_inventory assert my_collection.inventory == [simple_inventory_node] assert my_collection.doi == new_cript_doi assert my_collection.citation == [complex_citation_node] + assert my_collection.notes == new_collection_notes # remove Collection attributes my_collection.experiment = [] my_collection.inventory = [] my_collection.doi = "" my_collection.citation = [] + my_collection.notes = "" # assert users can remove optional attributes assert my_collection.name == new_collection_name @@ -97,6 +97,7 @@ def test_collection_getters_and_setters(simple_experiment_node, simple_inventory assert my_collection.inventory == [] assert my_collection.doi == "" assert my_collection.citation == [] + assert my_collection.notes == "" def test_serialize_collection_to_json(complex_user_node) -> None: diff --git a/tests/nodes/primary_nodes/test_computation.py b/tests/nodes/primary_nodes/test_computation.py index 6c4c275c8..9657cb40c 100644 --- a/tests/nodes/primary_nodes/test_computation.py +++ b/tests/nodes/primary_nodes/test_computation.py @@ -30,6 +30,7 @@ def test_create_complex_computation_node(simple_data_node, complex_software_conf test that a complex computation node with all possible arguments can be created """ my_computation_type = "analysis" + my_computation_notes = "this is my computation notes" citation = copy.deepcopy(complex_citation_node) condition = copy.deepcopy(complex_condition_node) @@ -42,6 +43,7 @@ def test_create_complex_computation_node(simple_data_node, complex_software_conf condition=[condition], prerequisite_computation=simple_computation_node, citation=[citation], + notes=my_computation_notes, ) # assertions @@ -53,6 +55,7 @@ def test_create_complex_computation_node(simple_data_node, complex_software_conf assert my_computation_node.condition == [condition] assert my_computation_node.prerequisite_computation == simple_computation_node assert my_computation_node.citation == [citation] + assert my_computation_node.notes == my_computation_notes def test_computation_type_invalid_vocabulary() -> None: diff --git a/tests/nodes/primary_nodes/test_computational_process.py b/tests/nodes/primary_nodes/test_computational_process.py index 4dbf5ed19..4b84c0a2d 100644 --- a/tests/nodes/primary_nodes/test_computational_process.py +++ b/tests/nodes/primary_nodes/test_computational_process.py @@ -41,6 +41,7 @@ def test_create_complex_computational_process( """ computational_process_name = "my computational process name" + computational_process_notes = "my computational process notes" computational_process_type = "cross_linking" ingredient = complex_ingredient_node @@ -55,6 +56,7 @@ def test_create_complex_computational_process( condition=[complex_condition_node], property=[simple_property_node], citation=[complex_citation_node], + notes=computational_process_notes, ) # assertions @@ -68,6 +70,7 @@ def test_create_complex_computational_process( assert my_computational_process.condition == [complex_condition_node] assert my_computational_process.property == [simple_property_node] assert my_computational_process.citation == [complex_citation_node] + assert my_computational_process.notes == computational_process_notes def test_computational_process_getters_and_setters(simple_computation_process_node, simple_data_node, simple_ingredient_node, simple_software_configuration, simple_condition_node, simple_property_node, complex_citation_node) -> None: diff --git a/tests/nodes/primary_nodes/test_data.py b/tests/nodes/primary_nodes/test_data.py index 4835389fb..6f3f6bcde 100644 --- a/tests/nodes/primary_nodes/test_data.py +++ b/tests/nodes/primary_nodes/test_data.py @@ -1,4 +1,3 @@ -import copy import json import uuid @@ -36,29 +35,32 @@ def test_create_complex_data_node( create a complex data node with all possible arguments """ - file_node = copy.deepcopy(complex_file_node) + my_notes = "my complex data node notes" + my_complex_data = cript.Data( name="my complex data node name", type="afm_amp", - file=[file_node], + file=[complex_file_node], sample_preparation=simple_process_node, computation=[simple_computation_node], computation_process=[simple_computational_process_node], material=[simple_material_node], process=[simple_process_node], # citation=[complex_citation_node], + notes=my_notes, ) # assertions assert isinstance(my_complex_data, cript.Data) assert my_complex_data.type == "afm_amp" - assert my_complex_data.file == [file_node] + assert my_complex_data.file == [complex_file_node] assert my_complex_data.sample_preparation == simple_process_node assert my_complex_data.computation == [simple_computation_node] assert my_complex_data.computation_process == [simple_computational_process_node] assert my_complex_data.material == [simple_material_node] assert my_complex_data.process == [simple_process_node] # assert my_complex_data.citation == [complex_citation_node] + assert my_complex_data.notes == my_notes def test_data_getters_and_setters( @@ -83,6 +85,7 @@ def test_data_getters_and_setters( None """ my_data_type = "afm_height" + my_data_notes = "my data getter setter notes" my_new_files = [ complex_file_node, @@ -105,6 +108,7 @@ def test_data_getters_and_setters( simple_data_node.material = [simple_material_node] simple_data_node.process = [simple_process_node] simple_data_node.citation = [complex_citation_node] + simple_data_node.notes = my_data_notes # assertions check getters and setters assert simple_data_node.type == my_data_type @@ -115,6 +119,7 @@ def test_data_getters_and_setters( assert simple_data_node.material == [simple_material_node] assert simple_data_node.process == [simple_process_node] assert simple_data_node.citation == [complex_citation_node] + assert simple_data_node.notes == my_data_notes # remove optional attributes simple_data_node.sample_preparation = [] @@ -123,6 +128,7 @@ def test_data_getters_and_setters( simple_data_node.material = [] simple_data_node.process = [] simple_data_node.citation = [] + simple_data_node.notes = "" # assert that optional attributes have been removed from data node assert simple_data_node.sample_preparation == [] @@ -131,6 +137,7 @@ def test_data_getters_and_setters( assert simple_data_node.material == [] assert simple_data_node.process == [] assert simple_data_node.citation == [] + assert simple_data_node.notes == "" def test_serialize_data_to_json(simple_data_node) -> None: diff --git a/tests/nodes/primary_nodes/test_inventory.py b/tests/nodes/primary_nodes/test_inventory.py index 202225d27..708cb2cbf 100644 --- a/tests/nodes/primary_nodes/test_inventory.py +++ b/tests/nodes/primary_nodes/test_inventory.py @@ -21,19 +21,24 @@ def test_get_and_set_inventory(simple_inventory_node) -> None: """ # create new materials material_1 = cript.Material(name="new material 1", identifier=[{"names": ["new material 1 alternative name"]}]) + my_notes = "my inventory notes" - # set inventory materials + # set inventory simple_inventory_node.material = [material_1] + simple_inventory_node.notes = my_notes # get and check inventory materials assert isinstance(simple_inventory_node, cript.Inventory) assert simple_inventory_node.material[-1] == material_1 + assert simple_inventory_node.notes == my_notes # remove optional attributes simple_inventory_node.material = [] + simple_inventory_node.notes = "" # assert that optional attributes have been removed assert simple_inventory_node.material == [] + assert simple_inventory_node.notes == "" def test_inventory_serialization(simple_inventory_node, simple_material_dict) -> None: diff --git a/tests/nodes/primary_nodes/test_material.py b/tests/nodes/primary_nodes/test_material.py index 5819b08bc..e37aba38c 100644 --- a/tests/nodes/primary_nodes/test_material.py +++ b/tests/nodes/primary_nodes/test_material.py @@ -17,13 +17,14 @@ def test_create_complex_material(simple_material_node, simple_computational_forc material_name = "my material name" identifier = [{"bigsmiles": "1234"}, {"bigsmiles": "4567"}] keyword = ["acetylene"] + material_notes = "my material notes" component = [simple_material_node] forcefield = [simple_computational_forcefield_node] my_property = [cript.Property(key="modulus_shear", type="min", value=1.23, unit="gram")] - my_material = cript.Material(name=material_name, identifier=identifier, keyword=keyword, component=component, process=simple_process_node, property=my_property, computational_forcefield=forcefield) + my_material = cript.Material(name=material_name, identifier=identifier, keyword=keyword, component=component, process=simple_process_node, property=my_property, computational_forcefield=forcefield, notes=material_notes) assert isinstance(my_material, cript.Material) assert my_material.name == material_name @@ -33,6 +34,7 @@ def test_create_complex_material(simple_material_node, simple_computational_forc assert my_material.process == simple_process_node assert my_material.property == my_property assert my_material.computational_forcefield == forcefield + assert my_material.notes == material_notes def test_invalid_material_keywords() -> None: @@ -53,6 +55,7 @@ def test_all_getters_and_setters(simple_material_node, simple_property_node, sim """ # new attributes new_name = "new material name" + new_notes = "new material notes" new_identifier = [{"bigsmiles": "6789"}] @@ -82,6 +85,7 @@ def test_all_getters_and_setters(simple_material_node, simple_property_node, sim simple_material_node.computational_forcefield = simple_computational_forcefield_node simple_material_node.keyword = new_material_keywords simple_material_node.component = new_components + simple_material_node.notes = new_notes # get all attributes and assert that they are equal to the setter assert simple_material_node.name == new_name @@ -91,18 +95,21 @@ def test_all_getters_and_setters(simple_material_node, simple_property_node, sim assert simple_material_node.computational_forcefield == simple_computational_forcefield_node assert simple_material_node.keyword == new_material_keywords assert simple_material_node.component == new_components + assert simple_material_node.notes == new_notes # remove optional attributes simple_material_node.property = [] simple_material_node.parent_material = None simple_material_node.computational_forcefield = None simple_material_node.component = [] + simple_material_node.notes = "" # assert optional attributes have been removed assert simple_material_node.property == [] assert simple_material_node.parent_material is None assert simple_material_node.computational_forcefield is None assert simple_material_node.component == [] + assert simple_material_node.notes == "" def test_serialize_material_to_json(complex_material_dict, complex_material_node) -> None: diff --git a/tests/nodes/primary_nodes/test_process.py b/tests/nodes/primary_nodes/test_process.py index 4031238e4..1babb5e5a 100644 --- a/tests/nodes/primary_nodes/test_process.py +++ b/tests/nodes/primary_nodes/test_process.py @@ -53,6 +53,8 @@ def test_complex_process_node(complex_ingredient_node, simple_equipment_node, co "annealing_sol", ] + my_notes = "my complex process notes" + # create complex process citation = copy.deepcopy(complex_citation_node) prop = cript.Property("n_neighbor", "value", 2.0, None) @@ -70,6 +72,7 @@ def test_complex_process_node(complex_ingredient_node, simple_equipment_node, co property=[prop], keyword=my_process_keywords, citation=[citation], + notes=my_notes, ) # assertions assert my_complex_process.type == my_process_type @@ -83,6 +86,7 @@ def test_complex_process_node(complex_ingredient_node, simple_equipment_node, co assert my_complex_process.property[-1] == prop assert my_complex_process.keyword[-1] == my_process_keywords[-1] assert my_complex_process.citation[-1] == citation + assert my_complex_process.notes == my_notes def test_process_getters_and_setters( @@ -107,36 +111,35 @@ def test_process_getters_and_setters( new_process_type = "blow_molding" new_process_description = "my new process description" new_process_keywords = "annealing_sol" + new_process_notes = "new process notes" # test setters simple_process_node.type = new_process_type simple_process_node.ingredient = [complex_ingredient_node] simple_process_node.description = new_process_description - equipment = complex_equipment_node - simple_process_node.equipment = [equipment] - product = simple_material_node - simple_process_node.product = [product] + simple_process_node.equipment = [complex_equipment_node] + simple_process_node.product = [simple_material_node] simple_process_node.waste = [simple_material_node] simple_process_node.prerequisite_process = [simple_process_node] simple_process_node.condition = [complex_condition_node] - prop = cript.Property("n_neighbor", "value", 2.0, None) - simple_process_node.property += [prop] + simple_process_node.property += [simple_property_node] simple_process_node.keyword = [new_process_keywords] - citation = copy.deepcopy(complex_citation_node) - simple_process_node.citation = [citation] + simple_process_node.citation = [complex_citation_node] + simple_process_node.notes = new_process_notes # test getters assert simple_process_node.type == new_process_type assert simple_process_node.ingredient == [complex_ingredient_node] assert simple_process_node.description == new_process_description - assert simple_process_node.equipment[-1] == equipment - assert simple_process_node.product[-1] == product + assert simple_process_node.equipment[-1] == complex_equipment_node + assert simple_process_node.product[-1] == simple_material_node assert simple_process_node.waste == [simple_material_node] assert simple_process_node.prerequisite_process == [simple_process_node] assert simple_process_node.condition == [complex_condition_node] - assert simple_process_node.property[-1] == prop + assert simple_process_node.property[-1] == simple_property_node assert simple_process_node.keyword == [new_process_keywords] - assert simple_process_node.citation[-1] == citation + assert simple_process_node.citation[-1] == complex_citation_node + assert simple_process_node.notes == new_process_notes # test that optional attributes can be successfully removed simple_process_node.ingredient = [] @@ -149,6 +152,7 @@ def test_process_getters_and_setters( simple_process_node.property = [] simple_process_node.keyword = [] simple_process_node.citation = [] + simple_process_node.notes = "" # assert that optional attributes have been removed assert simple_process_node.ingredient == [] @@ -161,6 +165,7 @@ def test_process_getters_and_setters( assert simple_process_node.property == [] assert simple_process_node.keyword == [] assert simple_process_node.citation == [] + assert simple_process_node.notes == "" def test_serialize_process_to_json(simple_process_node) -> None: diff --git a/tests/nodes/primary_nodes/test_project.py b/tests/nodes/primary_nodes/test_project.py index 6d769708b..3812a1e60 100644 --- a/tests/nodes/primary_nodes/test_project.py +++ b/tests/nodes/primary_nodes/test_project.py @@ -33,24 +33,29 @@ def test_project_getters_and_setters(simple_project_node, simple_collection_node 4. what was set and what was gotten should be equivalent """ new_project_name = "my new project name" + new_project_notes = "my new project notes" # set attributes simple_project_node.name = new_project_name simple_project_node.collection = [complex_collection_node] simple_project_node.material = [simple_material_node] + simple_project_node.notes = new_project_notes # get attributes and assert that they are the same assert simple_project_node.name == new_project_name assert simple_project_node.collection == [complex_collection_node] assert simple_project_node.material == [simple_material_node] + assert simple_project_node.notes == new_project_notes # remove optional attributes simple_project_node.collection = [] simple_project_node.material = [] + simple_project_node.notes = "" # assert optional attributes have been removed assert simple_project_node.collection == [] assert simple_project_node.material == [] + assert simple_project_node.notes == "" def test_serialize_project_to_json(complex_project_node, complex_project_dict) -> None: diff --git a/tests/nodes/supporting_nodes/test_file.py b/tests/nodes/supporting_nodes/test_file.py index 78b6401ea..8a82f9914 100644 --- a/tests/nodes/supporting_nodes/test_file.py +++ b/tests/nodes/supporting_nodes/test_file.py @@ -140,26 +140,31 @@ def test_file_getters_and_setters(complex_file_node) -> None: new_file_type = "computation_config" new_file_extension = ".csv" new_data_dictionary = "new data dictionary" + new_notes = "new notes" # ------- set properties ------- complex_file_node.source = new_source complex_file_node.type = new_file_type complex_file_node.extension = new_file_extension complex_file_node.data_dictionary = new_data_dictionary + complex_file_node.notes = new_notes # ------- assert set and get properties are the same ------- assert complex_file_node.source == new_source assert complex_file_node.type == new_file_type assert complex_file_node.extension == new_file_extension assert complex_file_node.data_dictionary == new_data_dictionary + assert complex_file_node.notes == new_notes # remove optional attributes complex_file_node.extension = "" complex_file_node.data_dictionary = "" + complex_file_node.notes = "" # assert optional attributes have been removed assert complex_file_node.extension == "" assert complex_file_node.data_dictionary == "" + assert complex_file_node.notes == "" def test_serialize_file_to_json(complex_file_node) -> None: