def test_getRequires_withRelationsSet(): model = SettingDefinitionsModel() model._container = MagicMock() relation_1 = MagicMock() relation_1.type = RelationType.RequiredByTarget relation_2 = MagicMock() relation_2.type = RelationType.RequiresTarget relation_2.role = "HERPDERP" relation_3 = MagicMock() relation_3.type = RelationType.RequiresTarget relation_3.role = "yay" relation_3.target.key = "key_3" relation_3.target.label = "label_3" mocked_definition_1 = MagicMock() mocked_definition_1.relations = [relation_1, relation_2, relation_3] model._container.findDefinitions = MagicMock(return_value=[mocked_definition_1]) assert model.getRequires("blorp", "yay") == [{"key": "key_3", "label": "label_3"}]
def test_getRequires_noDefinition(): model = SettingDefinitionsModel() model._container = MagicMock() model._container.findDefinitions = MagicMock(return_value=[]) assert model.getRequires("blorp", "whatever") == []
def test_getRequires_noContainer(): model = SettingDefinitionsModel() assert model.getRequires("blorp", "whatever") == []