def test_merge_model_with_multi_table_inheritance(self): primary_object = NewsAgencyFactory.create(address=None, website=None) alias_object = NewsAgencyFactory.create() merged_object = MergedModelInstance.create(primary_object, [alias_object]) assert merged_object.address == alias_object.address assert merged_object.website == alias_object.website
def test_o2m_merge_with_audit_trail(self): primary_object = NewsAgencyFactory.create() alias_object = NewsAgencyFactory.create() related_objects = set( ReporterFactory.create_batch(3, news_agency=alias_object)) _, audit_trail = MergedModelInstance.create_with_audit_trail( primary_object, [alias_object]) assert set(audit_trail) == related_objects
def test_merge_model_with_o2m_relationship(self): primary_object = NewsAgencyFactory.create() alias_object = NewsAgencyFactory.create() related_object = ReporterFactory.create(news_agency=alias_object) merged_object = MergedModelInstance.create(primary_object, [alias_object]) assert related_object.news_agency != merged_object related_object.refresh_from_db() assert related_object.news_agency == merged_object