コード例 #1
0
    def test_dedupe_model_with_o2o_relationship_no_merge(self):
        primary_object = RestaurantFactory.create(place=None,
                                                  serves_hot_dogs=True,
                                                  serves_pizza=False)
        alias_object = RestaurantFactory.create(serves_hot_dogs=False,
                                                serves_pizza=True)

        merged_object = MergedModelInstance.create(primary_object,
                                                   [alias_object],
                                                   merge_field_values=False)

        assert not merged_object.place
        assert merged_object.serves_hot_dogs and not merged_object.serves_pizza
コード例 #2
0
    def test_merge_model_with_o2o_relationship(self):
        primary_object = RestaurantFactory.create(place=None,
                                                  serves_hot_dogs=True,
                                                  serves_pizza=False)
        alias_object = RestaurantFactory.create(serves_hot_dogs=False,
                                                serves_pizza=True)
        alias_address = alias_object.place.address
        alias_name = alias_object.place.name

        merged_object = MergedModelInstance.create(primary_object,
                                                   [alias_object])

        assert merged_object.place.address == alias_address
        assert merged_object.place.name == alias_name
        assert merged_object.serves_hot_dogs and not merged_object.serves_pizza
コード例 #3
0
    def test_o2o_merge_with_audit_trail(self):
        primary_object = RestaurantFactory.create(place=None,
                                                  serves_hot_dogs=True,
                                                  serves_pizza=False)
        alias_objects = RestaurantFactory.create_batch(3)
        related_object = set([alias_objects[0].place])

        _, audit_trail = MergedModelInstance.create_with_audit_trail(
            primary_object, alias_objects)

        assert set(audit_trail) == related_object