def test_same_url_dont_create(self):
     instance = TestModel.objects.create(slug='initial')
     url_method = URLChangeMethod.objects.create(
         content_object=instance,
         method_name='get_absolute_url',
     )
     url_method.old_urls.create(url=reverse_model('initial'))
     track_changed_url(instance)
     self.assertEqual(URLChangeMethod.objects.count(), 0)
 def test_save_current_url(self):
     instance = TestModel.objects.create(slug='current')
     url_method = URLChangeMethod.objects.create(
         content_object=instance,
         method_name='get_absolute_url',
     )
     url_method.old_urls.create(url=reverse_model('another'))
     track_changed_url(instance)
     self.assertEqual(URLChangeMethod.objects.count(), 1)
     url_method = URLChangeMethod.objects.all()[0]
     self.assertEqual(url_method.current_url, reverse_model('current'))
    def test_url_no_reverse_dont_create(self):
        instance = TestModel.objects.create(slug='//')
        track_changed_url(instance)

        self.assertFalse(URLChangeMethod.objects.count())
    def test_no_url_change_method(self):
        instance = TestModel.objects.create()
        track_changed_url(instance)

        self.assertFalse(URLChangeMethod.objects.count())