コード例 #1
0
    def test_cdm_trait_collection_remove_only_from_property(self):
        manifest = generate_manifest('C:\\Root\\Path')

        trait = CdmTraitReference(manifest.ctx, 'TraitName', None)
        other_trait = CdmTraitReference(manifest.ctx, 'Name of other Trait',
                                        None)

        manifest.exhibits_traits.append(trait)
        manifest.exhibits_traits.append(other_trait)

        self.assertFalse(trait.is_from_property)
        self.assertFalse(other_trait.is_from_property)

        self.assertEqual(2, len(manifest.exhibits_traits))
        manifest.exhibits_traits.remove(trait, True)
        self.assertTrue(trait in manifest.exhibits_traits)
        self.assertEqual(2, len(manifest.exhibits_traits))

        other_trait.is_from_property = True

        manifest.exhibits_traits.remove(other_trait, True)
        self.assertTrue(other_trait not in manifest.exhibits_traits)

        self.assertEqual(1, len(manifest.exhibits_traits))
        self.assertEqual(trait, manifest.exhibits_traits[0])
コード例 #2
0
    def test_cdm_trait_collection_remove_prioritize_from_property(self):
        manifest = generate_manifest("C:\\Root\\Path")

        trait = CdmTraitReference(manifest.ctx, "TraitName", None)
        other_trait = CdmTraitReference(manifest.ctx, "Name of other Trait",
                                        None)

        manifest.exhibits_traits.append(trait)
        manifest.exhibits_traits.append(other_trait)

        trait_copy_from_property = CdmTraitReference(manifest.ctx, "TraitName",
                                                     None)
        trait_copy_from_property.is_from_property = True
        manifest.exhibits_traits.append(trait_copy_from_property)

        self.assertEqual(3, len(manifest.exhibits_traits))
        manifest.exhibits_traits.remove("TraitName")
        self.assertTrue(
            trait_copy_from_property not in manifest.exhibits_traits)
        self.assertEqual(2, len(manifest.exhibits_traits))
        self.assertEqual(trait, manifest.exhibits_traits[0])
        self.assertEqual(other_trait, manifest.exhibits_traits[1])