Ejemplo n.º 1
0
    def test_manifest_add_entity_with_localized_paths(self):
        manifest = generate_manifest("C:\\Root\\Path")
        cdm_corpus = manifest.ctx.corpus

        entity = CdmEntityDefinition(cdm_corpus.ctx, "entityName", None)
        entity.explanation = "The explanation of the entity"

        create_document_for_entity(cdm_corpus, entity)

        cdm_entity = CdmEntityDefinition(cdm_corpus.ctx, "cdm_entityName",
                                         None)
        create_document_for_entity(cdm_corpus, cdm_entity, "cdm")

        localized_entity_declaration = manifest.entities.append(entity)
        cdm_entity_declaration = manifest.entities.append(cdm_entity)

        self.assertEqual("The explanation of the entity",
                         localized_entity_declaration.explanation)
        self.assertEqual("entityName.cdm.json/entityName",
                         localized_entity_declaration.entity_path)
        self.assertEqual("entityName",
                         localized_entity_declaration.entity_name)
        self.assertEqual("cdm:/cdm_entityName.cdm.json/cdm_entityName",
                         cdm_entity_declaration.entity_path)
        self.assertEqual("entityName",
                         localized_entity_declaration.entity_name)

        self.assertEqual(2, len(manifest.entities))
        self.assertEqual(localized_entity_declaration, manifest.entities[0])
        self.assertEqual(cdm_entity_declaration, manifest.entities[1])
Ejemplo n.º 2
0
    def test_manifest_can_add_entity_definition(self):
        manifest = generate_manifest("C:\\Root\\Path")
        entity = CdmEntityDefinition(manifest.ctx, "entityName", None)

        entity.explanation = "The explanation of the entity"

        create_document_for_entity(manifest.ctx.corpus, entity)

        entity_declaration = manifest.ctx.corpus.make_object(
            CdmObjectType.LOCAL_ENTITY_DECLARATION_DEF, entity.entity_name,
            False)  # type: CdmLocalEntityDeclarationDefinition
        entity_declaration.entity_path = '{}/{}'.format(
            entity.owner.at_corpus_path, entity.entity_name)

        manifest.entities.append(entity_declaration)

        self.assertEqual("local:/entityName.cdm.json/entityName",
                         entity_declaration.entity_path)
        self.assertEqual("entityName", entity_declaration.entity_name)

        self.assertEqual(1, len(manifest.entities))
        self.assertEqual(entity_declaration, manifest.entities[0])
Ejemplo n.º 3
0
    def test_manifest_add_entity_with_localized_paths(self):
        manifest = generate_manifest()
        cdm_corpus = manifest.ctx.corpus

        entity = CdmEntityDefinition(cdm_corpus.ctx, 'entityName', None)
        entity.explanation = 'The explanation of the entity'

        create_document_for_entity(cdm_corpus, entity)

        cdm_entity = CdmEntityDefinition(cdm_corpus.ctx, 'cdm_entityName', None)
        create_document_for_entity(cdm_corpus, cdm_entity, 'cdm')

        localized_entity_declaration = manifest.entities.append(entity)
        cdm_entity_declaration = manifest.entities.append(cdm_entity)

        self.assertEqual('The explanation of the entity', localized_entity_declaration.explanation)
        self.assertEqual('entityName.cdm.json/entityName', localized_entity_declaration.entity_path)
        self.assertEqual('entityName', localized_entity_declaration.entity_name)
        self.assertEqual('cdm:/cdm_entityName.cdm.json/cdm_entityName', cdm_entity_declaration.entity_path)
        self.assertEqual('entityName', localized_entity_declaration.entity_name)

        self.assertEqual(2, len(manifest.entities))
        self.assertEqual(localized_entity_declaration, manifest.entities[0])
        self.assertEqual(cdm_entity_declaration, manifest.entities[1])