Example #1
0
    def test_read_from_yaml(self):
        entity_no_tag = Entity.from_yaml(
            "tests/sample/valid_entity_no_tag.yaml")
        assert entity_no_tag.name == "myentity"
        assert entity_no_tag.description == "test entity without tag"
        assert len(entity_no_tag.tags) == 0

        entity = Entity.from_yaml("tests/sample/valid_entity.yaml")
        assert entity.name == "myentity"
        assert entity.description == "test entity with tag"
        assert entity.tags[0] == "tag1"
        assert entity.tags[1] == "tag2"
Example #2
0
def _register_resources(client, entities_fldr, features_fldr):
    resources = []
    for ent_file in os.listdir(entities_fldr):
        resources.append(Entity.from_yaml(os.path.join(entities_fldr, ent_file)))
    for feat_file in os.listdir(features_fldr):
        resources.append(Feature.from_yaml(os.path.join(features_fldr, feat_file)))
    client.apply(resources)
Example #3
0
    def test_dump(self):
        entity = Entity("entity", "description", ["tag1", "tag2"])
        entity.dump("myentity.yaml")
        actual = Entity.from_yaml("myentity.yaml")
        assert actual.name == entity.name
        assert actual.description == entity.description
        for t1, t2 in zip(actual.tags, entity.tags):
            assert t1 == t2

        #cleanup
        os.remove("myentity.yaml")