def test_blank_title_is_not_in_dictionary_after_clearing(): test_entry = Entry() test_entry.title = ("MY_TITLE", False) test_entry.title = ("", False) dictionary = test_entry.as_dict([]) assert find_child_dataset_by_name(dictionary, NEXUS_TITLE_NAME) is None
def test_blank_proposal_id_is_not_in_dictionary_after_clearing(): test_entry = Entry() test_entry.proposal_id = ("MY_PROP_ID", False) test_entry.proposal_id = ("", False) dictionary = test_entry.as_dict([]) assert find_child_dataset_by_name(dictionary, NEXUS_EXP_ID_NAME) is None
def test_defined_proposal_id_is_in_dictionary(): test_entry = Entry() test_entry.proposal_id = ("MY_PROP_ID", False) dictionary = test_entry.as_dict([]) result = find_child_dataset_by_name(dictionary, NEXUS_EXP_ID_NAME) assert result is not None assert result["config"]["values"] == "MY_PROP_ID"
def test_defined_title_is_in_dictionary(): test_entry = Entry() test_entry.title = ("MY_TITLE", False) dictionary = test_entry.as_dict([]) result = find_child_dataset_by_name(dictionary, NEXUS_TITLE_NAME) assert result is not None assert result["config"]["values"] == "MY_TITLE"
def test_if_placeholder_used_then_users_replaced_by_placeholder(): user_john = { "name": "John Smith", "email": "*****@*****.**", "facility_user_id": "js90", "affiliation": "ESS", } test_entry = Entry() test_entry.users = [user_john] test_entry.users_placeholder = True dictionary = test_entry.as_dict([]) assert len(extract_based_on_nx_class(dictionary, NX_USER)) == 0 assert USERS_PLACEHOLDER in dictionary["children"]
class Model: def __init__(self): self.signals = Signals() self.entry = Entry() self._components: Dict = {} def append_component(self, component: Component): self._components[component.absolute_path] = component def remove_component(self, component: Component): self._components.pop(component.absolute_path) def get_components(self): return [item for item in self._components.values()] def as_dict(self, error_collector: List[str]) -> Dict[str, Any]: return {CommonKeys.CHILDREN: [self.entry.as_dict(error_collector)]}
def test_users_are_in_dictionary(): user_john = { "name": "John Smith", "email": "*****@*****.**", "facility_user_id": "js90", "affiliation": "ESS", } user_betty = { "name": "Betty Boo", "email": "*****@*****.**", "facility_user_id": "bb70", "affiliation": "She Rockers", } test_entry = Entry() test_entry.users = [user_john, user_betty] dictionary = test_entry.as_dict([]) result = extract_based_on_nx_class(dictionary, NX_USER) assert_matching_datasets_exist(result[0], user_john) assert_matching_datasets_exist(result[1], user_betty)
def test_blank_proposal_id_is_not_in_dictionary(): test_entry = Entry() dictionary = test_entry.as_dict([]) assert find_child_dataset_by_name(dictionary, NEXUS_EXP_ID_NAME) is None
def test_blank_title_is_not_in_dictionary(): test_entry = Entry() dictionary = test_entry.as_dict([]) assert find_child_dataset_by_name(dictionary, NEXUS_TITLE_NAME) is None