Ejemplo n.º 1
0
    def test_merge_entities_attribute_duplication(self):
        merge_entities([self.apple_id, self.apricot_id], self.applicot_id)

        applicot = Entity.objects.get(name="Applicot")

        self.assertEqual(6, EntityAttribute.objects.count())
        self.assertEqual(6, applicot.attributes.count())
        self.assertEqual(
            1,
            applicot.attributes.filter(namespace='color', value='red').count())
        self.assertEqual(
            1,
            applicot.attributes.filter(namespace='color',
                                       value='yellow').count())
        self.assertEqual(
            1,
            applicot.attributes.filter(namespace='texture',
                                       value='crisp').count())
        self.assertEqual(
            1,
            applicot.attributes.filter(namespace='texture',
                                       value='soft').count())
        self.assertEqual(
            1,
            applicot.attributes.filter(
                namespace=EntityAttribute.ENTITY_ID_NAMESPACE,
                value=self.apple_id).count())
        self.assertEqual(
            1,
            applicot.attributes.filter(
                namespace=EntityAttribute.ENTITY_ID_NAMESPACE,
                value=self.apricot_id).count())
Ejemplo n.º 2
0
    def test_merge_entities_attribute_duplication(self):
        merge_entities([self.apple_id, self.apricot_id], self.applicot_id)

        applicot = Entity.objects.get(name="Applicot")

        self.assertEqual(6, EntityAttribute.objects.count())
        self.assertEqual(6, applicot.attributes.count())
        self.assertEqual(1, applicot.attributes.filter(namespace='color', value='red').count())
        self.assertEqual(1, applicot.attributes.filter(namespace='color', value='yellow').count())
        self.assertEqual(1, applicot.attributes.filter(namespace='texture', value='crisp').count())
        self.assertEqual(1, applicot.attributes.filter(namespace='texture', value='soft').count())
        self.assertEqual(1, applicot.attributes.filter(namespace=EntityAttribute.ENTITY_ID_NAMESPACE, value=self.apple_id).count())
        self.assertEqual(1, applicot.attributes.filter(namespace=EntityAttribute.ENTITY_ID_NAMESPACE, value=self.apricot_id).count())
Ejemplo n.º 3
0
    def test_merge_entities(self):
        merge_entities([self.apple_id, self.apricot_id], self.applicot_id)

        self.assertEqual(1, Entity.objects.count())
        applicot = Entity.objects.get(name="Applicot")
        self.assertEqual(self.applicot_id, applicot.id.hex)

        self.assertEqual(4, EntityAlias.objects.count())
        self.assertEqual(4, applicot.aliases.count())
        self.assertEqual(1, applicot.aliases.filter(alias='Apple').count())
        self.assertEqual(1, applicot.aliases.filter(alias='Apple Juice').count())
        self.assertEqual(1, applicot.aliases.filter(alias='Apricot').count())
        self.assertEqual(1, applicot.aliases.filter(alias='Applicot').count())
Ejemplo n.º 4
0
    def test_merge_entities(self):
        merge_entities([self.apple_id, self.apricot_id], self.applicot_id)

        self.assertEqual(1, Entity.objects.count())
        applicot = Entity.objects.get(name="Applicot")
        self.assertEqual(self.applicot_id, applicot.id.hex)

        self.assertEqual(4, EntityAlias.objects.count())
        self.assertEqual(4, applicot.aliases.count())
        self.assertEqual(1, applicot.aliases.filter(alias='Apple').count())
        self.assertEqual(1,
                         applicot.aliases.filter(alias='Apple Juice').count())
        self.assertEqual(1, applicot.aliases.filter(alias='Apricot').count())
        self.assertEqual(1, applicot.aliases.filter(alias='Applicot').count())
Ejemplo n.º 5
0
    def test_merge_entities_alias_duplication(self):
        apple = Entity.objects.get(id=self.apple_id)
        apple.aliases.create(alias="Delicious")

        apricot = Entity.objects.get(id=self.apricot_id)
        apricot.aliases.create(alias="Delicious")

        merge_entities([self.apple_id, self.apricot_id], self.applicot_id)

        applicot = Entity.objects.get(name="Applicot")

        self.assertEqual(5, EntityAlias.objects.count())
        self.assertEqual(5, applicot.aliases.count())
        self.assertEqual(1, applicot.aliases.filter(alias='Apple').count())
        self.assertEqual(1, applicot.aliases.filter(alias='Apple Juice').count())
        self.assertEqual(1, applicot.aliases.filter(alias='Apricot').count())
        self.assertEqual(1, applicot.aliases.filter(alias='Applicot').count())
        self.assertEqual(1, applicot.aliases.filter(alias='Delicious').count())
Ejemplo n.º 6
0
    def test_merge_entities_alias_duplication(self):
        apple = Entity.objects.get(id=self.apple_id)
        apple.aliases.create(alias="Delicious")

        apricot = Entity.objects.get(id=self.apricot_id)
        apricot.aliases.create(alias="Delicious")

        merge_entities([self.apple_id, self.apricot_id], self.applicot_id)

        applicot = Entity.objects.get(name="Applicot")

        self.assertEqual(5, EntityAlias.objects.count())
        self.assertEqual(5, applicot.aliases.count())
        self.assertEqual(1, applicot.aliases.filter(alias='Apple').count())
        self.assertEqual(1,
                         applicot.aliases.filter(alias='Apple Juice').count())
        self.assertEqual(1, applicot.aliases.filter(alias='Apricot').count())
        self.assertEqual(1, applicot.aliases.filter(alias='Applicot').count())
        self.assertEqual(1, applicot.aliases.filter(alias='Delicious').count())