def test_copy_new_object(self): """ Objects that didn't exist in the copy_to database should be correctly be copied from the default database to the copy_to database. """ queue = qc.copy_following_relationships(self.seosites, copy_to=self.copy_to) self.confirm_complete(queue) query_base = models.SeoSite.objects.using(self.copy_to) new_seosite = query_base.get(pk=self.seosite.pk) self.confirm_copy( self.seosite, new_seosite, self.site_foreign_key_field_names, self.site_null_foreign_key_field_names, self.site_many_to_many_field_names, ) # Do a sanity check to confirm that they really are seperate objects. new_seosite.domain = "updatedseosite.jobs" # It knows what db it came from. new_seosite.save() seosite = models.SeoSite.objects.get(pk=self.seosite) self.assertNotEqual(new_seosite.domain, seosite)
def test_copy_update_object(self): """ Objects that already existed in the copy_to dabase should be correctly overwritten in the copy_to database using the data from the default database. """ factories.SeoSiteCopyToFactory(id=self.seosite.pk) # Confirm we're working with two different objects. site = models.SeoSite.objects.get(pk=self.seosite) query_base = models.SeoSite.objects.using(self.copy_to) copied_site = query_base.get(pk=self.seosite) self.assertNotEqual(site.domain, copied_site.domain) queue = qc.copy_following_relationships(self.seosites, copy_to=self.copy_to) self.confirm_complete(queue) new_obj = query_base.get(pk=self.seosite.pk) self.confirm_copy( self.seosite, new_obj, self.site_foreign_key_field_names, self.site_null_foreign_key_field_names, self.site_many_to_many_field_names, ) # Confirm the object has been updated in the self.copy_to database. site = models.SeoSite.objects.get(pk=self.seosite) query_base = models.SeoSite.objects.using(self.copy_to) copied_site = query_base.get(pk=self.seosite) self.assertEqual(site.domain, copied_site.domain)
def test_copy_update_object(self): """ Objects that already existed in the copy_to dabase should be correctly overwritten in the copy_to database using the data from the default database. """ factories.SeoSiteCopyToFactory(id=self.seosite.pk) # Confirm we're working with two different objects. site = models.SeoSite.objects.get(pk=self.seosite) query_base = models.SeoSite.objects.using(self.copy_to) copied_site = query_base.get(pk=self.seosite) self.assertNotEqual(site.domain, copied_site.domain) queue = qc.copy_following_relationships(self.seosites, copy_to=self.copy_to) self.confirm_complete(queue) new_obj = query_base.get(pk=self.seosite.pk) self.confirm_copy(self.seosite, new_obj, self.site_foreign_key_field_names, self.site_null_foreign_key_field_names, self.site_many_to_many_field_names) # Confirm the object has been updated in the self.copy_to database. site = models.SeoSite.objects.get(pk=self.seosite) query_base = models.SeoSite.objects.using(self.copy_to) copied_site = query_base.get(pk=self.seosite) self.assertEqual(site.domain, copied_site.domain)
def test_copy_new_object(self): """ Objects that didn't exist in the copy_to database should be correctly be copied from the default database to the copy_to database. """ queue = qc.copy_following_relationships(self.seosites, copy_to=self.copy_to) self.confirm_complete(queue) query_base = models.SeoSite.objects.using(self.copy_to) new_seosite = query_base.get(pk=self.seosite.pk) self.confirm_copy(self.seosite, new_seosite, self.site_foreign_key_field_names, self.site_null_foreign_key_field_names, self.site_many_to_many_field_names) # Do a sanity check to confirm that they really are seperate objects. new_seosite.domain = 'updatedseosite.jobs' # It knows what db it came from. new_seosite.save() seosite = models.SeoSite.objects.get(pk=self.seosite) self.assertNotEqual(new_seosite.domain, seosite)