Esempio n. 1
0
    async def test_extends_entity_proj(self):
        """AddTypeAttribute on an entity definition"""
        test_name = 'test_extends_entity_proj'
        entity_name = 'Customer'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(
                self, corpus, test_name, self.tests_subpath, entity_name,
                res_opt)

        entity = await corpus.fetch_object_async(
            'local:/{}.cdm.json/{}'.format(entity_name, entity_name))
        resolved_entity = await ProjectionTestUtils.get_resolved_entity(
            corpus, entity, [])

        # Original set of attributes: ["emailId", "address", "isPrimary", "phoneId", "number", "socialId", "account"]
        # Type attribute: "someType"
        self.assertEqual(8, len(resolved_entity.attributes))
        self.assertEqual('emailId', resolved_entity.attributes[0].name)
        self.assertEqual('address', resolved_entity.attributes[1].name)
        self.assertEqual('isPrimary', resolved_entity.attributes[2].name)
        self.assertEqual('phoneId', resolved_entity.attributes[3].name)
        self.assertEqual('number', resolved_entity.attributes[4].name)
        self.assertEqual('socialId', resolved_entity.attributes[5].name)
        self.assertEqual('account', resolved_entity.attributes[6].name)
        self.assertEqual('someType', resolved_entity.attributes[7].name)
        self.assertIsNotNone(resolved_entity.attributes[7].applied_traits.item(
            'is.linkedEntity.name'))
    async def test_group(self):
        """CountAttribute on an entity with an attribute group"""
        test_name = 'test_group'
        entity_name = 'NewPerson'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(
                self, corpus, test_name, self.tests_subpath, entity_name,
                res_opt)

        entity = await corpus.fetch_object_async(
            'local:/{}.cdm.json/{}'.format(entity_name, entity_name))
        resolved_entity = await ProjectionTestUtils.get_resolved_entity(
            corpus, entity, [])

        # Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
        # Count attribute: "someCount"
        # For resolution guidance, CountAttribute has to be used with Expansion so we do an Expansion of 1...1 here
        self.assertEqual(6, len(resolved_entity.attributes))
        self.assertEqual('someCount', resolved_entity.attributes[0].name)
        self.assertEqual(
            'is.linkedEntity.array.count',
            resolved_entity.attributes[0].applied_traits[1].named_reference)
        self.assertEqual('name1', resolved_entity.attributes[1].name)
        self.assertEqual('age1', resolved_entity.attributes[2].name)
        self.assertEqual('address1', resolved_entity.attributes[3].name)
        self.assertEqual('phoneNumber1', resolved_entity.attributes[4].name)
        self.assertEqual('email1', resolved_entity.attributes[5].name)
    async def test_duplicate(self):
        """Two AddCountAttribute operations in a single projection using the same Count attribute"""
        test_name = 'test_duplicate'
        entity_name = 'NewPerson'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(
                self, corpus, test_name, self.tests_subpath, entity_name,
                res_opt)

        entity = await corpus.fetch_object_async(
            'local:/{}.cdm.json/{}'.format(entity_name, entity_name))
        resolved_entity = await ProjectionTestUtils.get_resolved_entity(
            corpus, entity, [])

        # Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
        # Count attribute: "someCount", count attribute: "someCount"
        # "someCount" should get merged into one
        self.assertEqual(6, len(resolved_entity.attributes))
        self.assertEqual('name', resolved_entity.attributes[0].name)
        self.assertEqual('age', resolved_entity.attributes[1].name)
        self.assertEqual('address', resolved_entity.attributes[2].name)
        self.assertEqual('phoneNumber', resolved_entity.attributes[3].name)
        self.assertEqual('email', resolved_entity.attributes[4].name)
        self.assertEqual('someCount', resolved_entity.attributes[5].name)
        self.assertEqual(
            'is.linkedEntity.array.count',
            resolved_entity.attributes[5].applied_traits[1].named_reference)
    async def test_conditional_proj(self):
        """AddCountAttribute with a conditionn"""
        test_name = 'test_conditional_proj'
        entity_name = 'NewPerson'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(
                self, corpus, test_name, self.tests_subpath, entity_name,
                res_opt)

        entity = await corpus.fetch_object_async(
            'local:/{}.cdm.json/{}'.format(entity_name, entity_name))
        resolved_entity = await ProjectionTestUtils.get_resolved_entity(
            corpus, entity, [])

        # Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
        # Count attribute: "someCount"
        # Condition is false, so no Count attribute added
        self.assertEqual(5, len(resolved_entity.attributes))
        self.assertEqual('name', resolved_entity.attributes[0].name)
        self.assertEqual('age', resolved_entity.attributes[1].name)
        self.assertEqual('address', resolved_entity.attributes[2].name)
        self.assertEqual('phoneNumber', resolved_entity.attributes[3].name)
        self.assertEqual('email', resolved_entity.attributes[4].name)
    async def test_combine_ops_nested_proj(self):
        """Nested projections with AddCountAttribute and other operations"""
        test_name = 'test_combine_ops_nested_proj'
        entity_name = 'NewPerson'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(
                self, corpus, test_name, self.tests_subpath, entity_name,
                res_opt)

        entity = await corpus.fetch_object_async(
            'local:/{}.cdm.json/{}'.format(entity_name, entity_name))
        resolved_entity = await ProjectionTestUtils.get_resolved_entity(
            corpus, entity, [])

        # Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
        # Count attribute: "someCount", renameFormat = new_{m}, include ["new_name", "age", "new_someCount"]
        self.assertEqual(3, len(resolved_entity.attributes))
        self.assertEqual('new_name', resolved_entity.attributes[0].name)
        self.assertEqual('new_age', resolved_entity.attributes[1].name)
        self.assertEqual('new_someCount', resolved_entity.attributes[2].name)
        self.assertEqual(
            'is.linkedEntity.array.count',
            resolved_entity.attributes[2].applied_traits[1].named_reference)
    async def test_combine_ops(self):
        """AddCountAttribute with other operations in the same projection"""
        test_name = 'test_combine_ops'
        entity_name = 'NewPerson'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(
                self, corpus, test_name, self.tests_subpath, entity_name,
                res_opt)

        entity = await corpus.fetch_object_async(
            'local:/{}.cdm.json/{}'.format(entity_name, entity_name))
        resolved_entity = await ProjectionTestUtils.get_resolved_entity(
            corpus, entity, [])

        # Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
        # Count attribute: "someCount", count attribute: "anotherCount", rename "name" to "firstName"
        self.assertEqual(8, len(resolved_entity.attributes))
        self.assertEqual('name', resolved_entity.attributes[0].name)
        self.assertEqual('age', resolved_entity.attributes[1].name)
        self.assertEqual('address', resolved_entity.attributes[2].name)
        self.assertEqual('phoneNumber', resolved_entity.attributes[3].name)
        self.assertEqual('email', resolved_entity.attributes[4].name)
        self.assertEqual('someCount', resolved_entity.attributes[5].name)
        self.assertEqual(
            'is.linkedEntity.array.count',
            resolved_entity.attributes[5].applied_traits[1].named_reference)
        self.assertEqual('anotherCount', resolved_entity.attributes[6].name)
        self.assertEqual(
            'is.linkedEntity.array.count',
            resolved_entity.attributes[6].applied_traits[1].named_reference)
        self.assertEqual('firstName', resolved_entity.attributes[7].name)
    async def test_with_nested_array_expansion(self):
        """Nested projections with ArrayExpansion, then AddCountAttribute, and then RenameAttributes"""
        test_name = 'test_with_nested_array_expansion'
        entity_name = 'NewPerson'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(
                self, corpus, test_name, self.tests_subpath, entity_name,
                res_opt)

        entity = await corpus.fetch_object_async(
            'local:/{}.cdm.json/{}'.format(entity_name, entity_name))
        resolved_entity = await ProjectionTestUtils.get_resolved_entity(
            corpus, entity, [])

        # Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
        # Count attribute: "personCount", expand 1...2, renameFormat = {m}{o}
        self.assertEqual(11, len(resolved_entity.attributes))
        self.assertEqual('name1', resolved_entity.attributes[0].name)
        self.assertEqual('age1', resolved_entity.attributes[1].name)
        self.assertEqual('address1', resolved_entity.attributes[2].name)
        self.assertEqual('phoneNumber1', resolved_entity.attributes[3].name)
        self.assertEqual('email1', resolved_entity.attributes[4].name)
        self.assertEqual('name2', resolved_entity.attributes[5].name)
        self.assertEqual('age2', resolved_entity.attributes[6].name)
        self.assertEqual('address2', resolved_entity.attributes[7].name)
        self.assertEqual('phoneNumber2', resolved_entity.attributes[8].name)
        self.assertEqual('email2', resolved_entity.attributes[9].name)
        self.assertEqual('personCount', resolved_entity.attributes[10].name)
        self.assertEqual(
            'is.linkedEntity.array.count',
            resolved_entity.attributes[10].applied_traits[1].named_reference)
    async def test_extends_entity(self):
        """CountAttribute on an entity definition"""
        test_name = 'test_extends_entity'
        entity_name = 'NewPerson'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(
                self, corpus, test_name, self.tests_subpath, entity_name,
                res_opt)

        entity = await corpus.fetch_object_async(
            'local:/{}.cdm.json/{}'.format(entity_name, entity_name))
        resolved_entity = await ProjectionTestUtils.get_resolved_entity(
            corpus, entity, [])

        # Original set of attributes: ["name", "age", "address", "phoneNumber", "email"]
        # Count attribute: "someCount"
        # For resolution guidance, CountAttribute has to be used with Expansion so we do an Expansion of 1...1 here
        # ExtendsEntityResolutionGuidance doesn't support doing expansions, so we only get the Count attribute
        self.assertEqual(1, len(resolved_entity.attributes))
        self.assertEqual('someCount', resolved_entity.attributes[0].name)
        self.assertEqual(
            'is.linkedEntity.array.count',
            resolved_entity.attributes[0].applied_traits[1].named_reference)
Esempio n. 9
0
    async def test_source_with_EA(self):
        test_name = 'test_source_with_EA'
        entity_name = 'SalesSourceWithEA'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_subpath, entity_name, res_opt)
Esempio n. 10
0
    async def test_nested_FK_proj(self):
        test_name = 'test_nested_FK_proj'
        entity_name = 'SalesNestedFK'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_subpath, entity_name, res_opt)
Esempio n. 11
0
    async def test_entity_attribute(self):
        test_name = 'test_entity_attribute'
        entity_name = 'SalesEntityAttribute'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_subpath, entity_name, res_opt)
Esempio n. 12
0
    async def test_polymorphic(self):
        test_name = 'test_polymorphic'
        entity_name = 'PersonPolymorphicSource'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_subpath, entity_name, res_opt)
Esempio n. 13
0
    async def test_foreign_key_always(self):
        test_name = 'test_foreign_key_always'
        entity_name = 'SalesForeignKeyAlways'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_subpath, entity_name, res_opt)
Esempio n. 14
0
    async def test_group_name_proj(self) -> None:
        """Test for include attributes operation by Group Name"""
        test_name = 'test_group_name_proj'
        entity_name = 'Product'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_sub_path)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_sub_path, entity_name, res_opt)
Esempio n. 15
0
    async def test_ea_proj(self) -> None:
        """Test for entity attribute with projection with an includeAttributes operation"""
        test_name = 'test_ea_proj'
        entity_name = 'Color'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_sub_path)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_sub_path, entity_name, res_opt)
Esempio n. 16
0
    async def test_nested_3_of_3_proj(self) -> None:
        """Test for top level projection"""
        test_name = 'test_nested_3_of_3_proj'
        entity_name = 'Color'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_sub_path)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_sub_path, entity_name, res_opt)
Esempio n. 17
0
    async def test_include_exclude_proj(self) -> None:
        """Test for  Projections with include and exclude"""
        test_name = 'test_include_exclude_proj'
        entity_name = 'Color'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_sub_path)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_sub_path, entity_name, res_opt)
Esempio n. 18
0
    async def test_polymorphic_proj(self) -> None:
        """Test for  Include Attributes from a Polymorphic Source"""
        test_name = 'test_polymorphic_proj'
        entity_name = 'Person'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_sub_path)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_sub_path, entity_name, res_opt)
Esempio n. 19
0
    async def test_array_proj(self) -> None:
        """Test for  Include Attributes from an Array"""
        test_name = 'test_array_proj'
        entity_name = 'Sales'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_sub_path)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_sub_path, entity_name, res_opt)
Esempio n. 20
0
    async def test_group_name(self) -> None:
        """Test for SelectsSomeTakeNames by Group Name"""
        test_name = 'test_group_name'
        entity_name = 'Product'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_sub_path)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_sub_path, entity_name, res_opt)
Esempio n. 21
0
    async def test_composite_key_proj(self):
        self.maxDiff = None
        test_name = 'test_composite_key_proj'
        entity_name = 'SalesCompositeKey'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_subpath, entity_name, res_opt)
Esempio n. 22
0
    async def test_array_rename(self) -> None:
        """Test for  SelectsSomeTakeNames from a renamed Array"""
        test_name = 'test_array_rename'
        entity_name = 'Sales'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_sub_path)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_sub_path, entity_name, res_opt)
Esempio n. 23
0
    async def test_ea(self) -> None:
        """Test for entity attribute with resolution guidance with a SelectsSomeTakeNames"""
        test_name = 'test_ea'
        entity_name = 'Color'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_sub_path)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_sub_path, entity_name, res_opt)
    async def test_conditional_proj_using_object_model(self):
        """Test for creating a projection with an AddAttributeGroup operation and a condition using the object model"""
        test_name = 'test_conditional_proj_using_object_model'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)
        local_root = corpus.storage.fetch_root_folder('local')

        # Create an entity.
        entity = ProjectionTestUtils.create_entity(corpus, local_root)

        # Create a projection with a condition that states the operation should only execute when the resolution directive is 'structured'.
        projection = ProjectionTestUtils.create_projection(corpus, local_root)
        projection.condition = 'structured==true'

        # Create an AddAttributeGroup operation
        add_att_group_op = corpus.make_object(CdmObjectType.OPERATION_ADD_ATTRIBUTE_GROUP_DEF)
        add_att_group_op.attribute_group_name = 'PersonAttributeGroup'
        projection.operations.append(add_att_group_op)

        # Create an entity reference to hold this projection.
        projection_entity_ref = corpus.make_object(CdmObjectType.ENTITY_REF, None)  # type: CdmEntityReference
        projection_entity_ref.explicit_reference = projection

        # Create an entity attribute that contains this projection and add this to the entity.
        entity_attribute = corpus.make_object(CdmObjectType.ENTITY_ATTRIBUTE_DEF, 'TestEntityAttribute')  # type: CdmEntityAttributeDefinition
        entity_attribute.entity = projection_entity_ref
        entity.attributes.append(entity_attribute)

        # Create resolution options with the 'referenceOnly' directive.
        res_opt = ResolveOptions(entity.in_document)
        res_opt.directives = AttributeResolutionDirectiveSet({'referenceOnly'})

        # Resolve the entity with 'referenceOnly'
        resolved_entity_with_reference_only = await entity.create_resolved_entity_async('Resolved_{}.cdm.json'.format(entity.entity_name), res_opt, local_root)

        # Verify correctness of the resolved attributes after running the AddAttributeGroup operation
        # Original set of attributes: ['id', 'name', 'value', 'date']
        # Condition not met, keep attributes in flat list
        self.assertEqual(4, len(resolved_entity_with_reference_only.attributes))
        self.assertEqual('id', resolved_entity_with_reference_only.attributes[0].name)
        self.assertEqual('name', resolved_entity_with_reference_only.attributes[1].name)
        self.assertEqual('value', resolved_entity_with_reference_only.attributes[2].name)
        self.assertEqual('date', resolved_entity_with_reference_only.attributes[3].name)

        # Now resolve the entity with the 'structured' directive
        res_opt.directives = AttributeResolutionDirectiveSet({'structured'})
        resolved_entity_with_structured = await entity.create_resolved_entity_async('Resolved_{}.cdm.json'.format(entity.entity_name), res_opt, local_root)

        # Verify correctness of the resolved attributes after running the AddAttributeGroup operation
        # Original set of attributes: ['id', 'name', 'value', 'date']
        # Condition met, put all attributes in an attribute group
        att_group_definition = self.validate_attribute_group(resolved_entity_with_structured.attributes, 'PersonAttributeGroup')
        self.assertEqual(4, len(att_group_definition.members))
        self.assertEqual('id', att_group_definition.members[0].name)
        self.assertEqual('name', att_group_definition.members[1].name)
        self.assertEqual('value', att_group_definition.members[2].name)
        self.assertEqual('date', att_group_definition.members[3].name)
Esempio n. 25
0
    async def test_multi_proj(self) -> None:
        """Test Multiple Nested Operations with Combine including ArrayExpansion and Rename"""
        self.maxDiff = None
        test_name = 'test_multi_proj'
        entity_name = 'Customer'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_sub_path)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_sub_path, entity_name, res_opt)
Esempio n. 26
0
    async def test_extends(self) -> None:
        """Test Entity Extends with a Resolution Guidance that selects 'one'"""
        self.maxDiff = None
        test_name = 'test_extends'
        entity_name = 'Customer'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_sub_path)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_sub_path, entity_name, res_opt)
Esempio n. 27
0
    async def test_ea_proj(self) -> None:
        """Test Entity Attribute with a Combine Attributes operation"""
        self.maxDiff = None
        test_name = 'test_ea_proj'
        entity_name = 'Customer'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_sub_path)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, \
                self.tests_sub_path, entity_name, res_opt)
    async def test_array_source(self):
        """SelectsSomeAvoidNames on an array source"""
        test_name = 'test_array_source'
        entity_name = 'FriendGroup'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(
                self, corpus, test_name, self.tests_subpath, entity_name,
                res_opt)

        entity = await corpus.fetch_object_async(
            'local:/{}.cdm.json/{}'.format(entity_name, entity_name))
        resolved_entity = await ProjectionTestUtils.get_resolved_entity(
            corpus, entity, [])

        # Original set of attributes: ['GroupOfPeoplePersonCount', 'GroupOfPeopleName1', 'GroupOfPeopleAge1', 'GroupOfPeopleAddress1',
        #                              'GroupOfPeoplePhoneNumber1', 'GroupOfPeopleEmail1', ..., 'GroupOfPeopleEmail3'] (16 total)
        # Excluded attributes: ['GroupOfPeopleAge1', 'GroupOfPeopleAge2', 'GroupOfPeopleAge3']
        self.assertEqual(13, len(resolved_entity.attributes))
        self.assertEqual('GroupOfPeoplePersonCount',
                         resolved_entity.attributes[0].name)
        self.assertEqual('GroupOfPeopleName1',
                         resolved_entity.attributes[1].name)
        self.assertEqual('GroupOfPeopleAddress1',
                         resolved_entity.attributes[2].name)
        self.assertEqual('GroupOfPeoplePhoneNumber1',
                         resolved_entity.attributes[3].name)
        self.assertEqual('GroupOfPeopleEmail1',
                         resolved_entity.attributes[4].name)
        self.assertEqual('GroupOfPeopleName2',
                         resolved_entity.attributes[5].name)
        self.assertEqual('GroupOfPeopleAddress2',
                         resolved_entity.attributes[6].name)
        self.assertEqual('GroupOfPeoplePhoneNumber2',
                         resolved_entity.attributes[7].name)
        self.assertEqual('GroupOfPeopleEmail2',
                         resolved_entity.attributes[8].name)
        self.assertEqual('GroupOfPeopleName3',
                         resolved_entity.attributes[9].name)
        self.assertEqual('GroupOfPeopleAddress3',
                         resolved_entity.attributes[10].name)
        self.assertEqual('GroupOfPeoplePhoneNumber3',
                         resolved_entity.attributes[11].name)
        self.assertEqual('GroupOfPeopleEmail3',
                         resolved_entity.attributes[12].name)
Esempio n. 29
0
    async def test_same_start_end_ordinals(self):
        """Same start and end ordinals"""
        test_name = 'test_same_start_end_ordinals'
        entity_name = 'ThreeMusketeers'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, self.tests_subpath, entity_name, res_opt)

        entity = await corpus.fetch_object_async('local:/{}.cdm.json/{}'.format(entity_name, entity_name))
        resolved_entity = await ProjectionTestUtils.get_resolved_entity(corpus, entity, [])

        # Original set of attributes: ["name", "age", "address"]
        # Expand 1...1, renameFormat = {m}{o}
        self.assertEqual(3, len(resolved_entity.attributes))
        self.assertEqual('name1', resolved_entity.attributes[0].name)
        self.assertEqual('age1', resolved_entity.attributes[1].name)
        self.assertEqual('address1', resolved_entity.attributes[2].name)
Esempio n. 30
0
    async def test_conditional_proj(self):
        """ArrayExpansion with a condition"""
        test_name = 'test_conditional_proj'
        entity_name = 'ThreeMusketeers'
        corpus = ProjectionTestUtils.get_corpus(test_name, self.tests_subpath)

        for res_opt in self.res_opts_combinations:
            await ProjectionTestUtils.load_entity_for_resolution_option_and_save(self, corpus, test_name, self.tests_subpath, entity_name, res_opt)

        entity = await corpus.fetch_object_async('local:/{}.cdm.json/{}'.format(entity_name, entity_name))
        resolved_entity = await ProjectionTestUtils.get_resolved_entity(corpus, entity, [])

        # Original set of attributes: ["name", "age", "address"]
        # Expand 1...3, renameFormat = {m}{o}
        # No array expansion, condition was false
        self.assertEqual(3, len(resolved_entity.attributes))
        self.assertEqual('name', resolved_entity.attributes[0].name)
        self.assertEqual('age', resolved_entity.attributes[1].name)
        self.assertEqual('address', resolved_entity.attributes[2].name)