def test_track_changed_url_with_unchanged_url(self):
        instance = self.tracked_model
        instance.get_absolute_url.return_value = u'/the/old/one/'
        instance._old_urls = {'get_absolute_url': u'/the/old/one/'}

        url_tracker.track_changed_url(instance)
        self.assertEquals(URLChangeRecord.objects.count(), 0)
    def test_create_delete_record_for_url_method_returning_none(self):
        instance = self.tracked_model
        instance.get_absolute_url.return_value = None
        instance._old_urls = {'get_absolute_url': u'/the/old/one/'}

        url_tracker.track_changed_url(instance)
        self.assertEquals(URLChangeRecord.objects.count(), 1)
        record = URLChangeRecord.objects.all()[0]
        self.assertEquals(record.deleted, True)
示例#3
0
    def test_track_changed_url_without_existing_records(self):
        instance = self.tracked_model
        instance._old_url = '/the/old/one/'

        url_tracker.track_changed_url(instance)
        self.assertEquals(URLChangeRecord.objects.count(), 1)
        record = URLChangeRecord.objects.all()[0]
        self.assertEquals(record.new_url, u'/the/new/one/')
        self.assertEquals(record.old_url, u'/the/old/one/')
        self.assertEquals(record.deleted, False)
    def test_track_changed_url_without_existing_records(self):
        instance = self.tracked_model
        instance.get_absolute_url.return_value = u'/the/new/one/'
        instance._old_urls = {'get_absolute_url': u'/the/old/one/'}

        url_tracker.track_changed_url(instance)
        self.assertEquals(URLChangeRecord.objects.count(), 1)
        record = URLChangeRecord.objects.all()[0]
        self.assertEquals(record.new_url, u'/the/new/one/')
        self.assertEquals(record.old_url, u'/the/old/one/')
        self.assertEquals(record.deleted, False)
示例#5
0
    def test_track_changed_url_deleting_exsiting_record_with_new_url(self):
        URLChangeRecord.objects.create(old_url='/the/new/one/', new_url='/the/')

        instance = self.tracked_model
        instance._old_url = '/the/old/one/'

        url_tracker.track_changed_url(instance)
        self.assertEquals(URLChangeRecord.objects.count(), 1)
        record = URLChangeRecord.objects.get(pk=1)
        self.assertEquals(record.old_url, u'/the/old/one/')
        self.assertEquals(record.new_url, u'/the/new/one/')
        self.assertEquals(record.deleted, False)
示例#6
0
    def test_track_changed_url_with_existing_deleted_record(self):
        URLChangeRecord.objects.create(old_url='/the/oldest/one/',
                                       new_url='/the/old/one/',
                                       deleted=True)
        URLChangeRecord.objects.create(old_url='/one/', new_url='/the/')

        instance = self.tracked_model
        instance._old_url = '/the/old/one/'

        url_tracker.track_changed_url(instance)

        record = URLChangeRecord.objects.get(pk=3)
        self.assertEquals(record.old_url, u'/the/old/one/')
        self.assertEquals(record.new_url, u'/the/new/one/')
        self.assertEquals(record.deleted, False)
    def test_track_changed_url_with_existing_records_and_old_url(self):
        URLChangeRecord.objects.create(old_url='/the/oldest/one/', new_url='/the/old/one/')
        URLChangeRecord.objects.create(old_url='/the/old/one/', new_url='/the/')

        instance = self.tracked_model
        instance.get_absolute_url.return_value = u'/the/new/one/'
        instance._old_urls = {'get_absolute_url': u'/the/old/one/'}

        url_tracker.track_changed_url(instance)
        self.assertEquals(URLChangeRecord.objects.count(), 2)
        record = URLChangeRecord.objects.get(pk=1)
        self.assertEquals(record.old_url, u'/the/oldest/one/')
        self.assertEquals(record.new_url, u'/the/new/one/')
        self.assertEquals(record.deleted, False)
        record = URLChangeRecord.objects.get(pk=2)
        self.assertEquals(record.old_url, u'/the/old/one/')
        self.assertEquals(record.new_url, u'/the/new/one/')
        self.assertEquals(record.deleted, False)
示例#8
0
    def test_track_changed_url_with_unchanged_url(self):
        instance = self.tracked_model
        instance._old_url = '/the/new/one/' 

        url_tracker.track_changed_url(instance)
        self.assertEquals(URLChangeRecord.objects.count(), 0)
示例#9
0
    def test_track_changed_url_with_new_instance(self):
        instance = self.tracked_model
        instance._old_url = None

        url_tracker.track_changed_url(instance)
        self.assertEquals(URLChangeRecord.objects.count(), 0)