Beispiel #1
0
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
Beispiel #2
0
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
Beispiel #3
0
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"
Beispiel #4
0
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"
Beispiel #5
0
def test_users_can_be_edited_using_simple_dict_representation():
    user_john = {
        "name": "John Smith",
        "email": "*****@*****.**",
        "facility_user_id": "js90",
        "affiliation": "ESS",
    }
    test_entry = Entry()

    test_entry.users = [user_john]

    assert test_entry.users == [user_john]
Beispiel #6
0
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"]
Beispiel #7
0
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)
Beispiel #8
0
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)]}
Beispiel #9
0
def test_title_is_initially_empty():
    test_entry = Entry()

    assert test_entry.title == ("", False)
Beispiel #10
0
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
Beispiel #11
0
def test_proposal_id_is_set_to_custom_value():
    test_entry = Entry()

    test_entry.proposal_id = ("MY_PROP_ID", False)

    assert test_entry.proposal_id == ("MY_PROP_ID", False)
Beispiel #12
0
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
Beispiel #13
0
 def __init__(self):
     self.signals = Signals()
     self.entry = Entry()
     self._components: Dict = {}
Beispiel #14
0
def test_users_is_initially_empty():
    test_entry = Entry()

    assert len(test_entry.users) == 0
Beispiel #15
0
def test_title_is_set_to_use_placeholder():
    test_entry = Entry()

    test_entry.title = ("will be ignored", True)

    assert test_entry.title == (TITLE_PLACEHOLDER_VALUE, True)
Beispiel #16
0
def test_proposal_id_is_initially_empty():
    test_entry = Entry()

    assert test_entry.proposal_id == ("", False)
Beispiel #17
0
def test_proposal_id_is_set_to_use_placeholder():
    test_entry = Entry()

    test_entry.proposal_id = ("will be ignored", True)

    assert test_entry.proposal_id == (EXP_ID_PLACEHOLDER_VALUE, True)
Beispiel #18
0
def instrument():
    return Entry(parent_node=None)
Beispiel #19
0
def test_title_is_set_to_custom_value():
    test_entry = Entry()

    test_entry.title = ("MY_TITLE", False)

    assert test_entry.title == ("MY_TITLE", False)