def test_lookup_url_with_existing_instance(self): def return_instance(pk): return self.tracked_db_model class_objects = Mock(name='MockModelManager') class_objects.get = return_instance self.tracked_model.__class__.objects = class_objects url_tracker.track_url_changes_for_model(Mock) url_tracker.lookup_previous_url(self.tracked_model) self.assertEquals(self.tracked_model._old_url, u'/the/old/one/')
def test_lookup_url_with_existing_instance(self): def return_instance(pk): return self.tracked_db_model class_objects = Mock(name='MockModelManager') class_objects.get = return_instance self.tracked_model.__class__.objects = class_objects self.tracked_model.get_absolute_url.return_value = u'/the/old/one/' url_tracker.track_url_changes_for_model(TrackedModelMock) url_tracker.lookup_previous_url(self.tracked_model) expected_dict = {'get_absolute_url': u'/the/old/one/'} self.assertEquals(self.tracked_model._old_urls, expected_dict)
def test__lookup_url_with_new_instance(self): url_tracker.track_url_changes_for_model(Mock) url_tracker.lookup_previous_url(self.tracked_model) self.assertEquals(self.tracked_model._old_url, None)