Permalink
Browse files

Add new test model and register in the admin with custom reversion ma…

…nager. Fix test case counting registered models.
  • Loading branch information...
1 parent 04c16f4 commit 8b46986a05900f2755b0eeecac194ad57359f590 @mlavin mlavin committed Jun 19, 2012
@@ -54,6 +54,7 @@
# Needs to import admin module to register all models via CompareVersionAdmin/VersionAdmin
import reversion_compare_test_project.reversion_compare_test_app.admin
+from reversion_compare_test_project.reversion_compare_test_app.admin import custom_revision_manager
class TestData(object):
@@ -274,7 +275,9 @@ def test_admin_login(self):
def test_model_registering(self):
test_app = get_app(app_label="reversion_compare_test_app")
models = get_models(app_mod=test_app, include_auto_created=False, include_deferred=False, only_installed=True)
- self.assertEqual(len(reversion.get_registered_models()), len(models))
+ default_registered = len(reversion.get_registered_models())
+ custom_registered = len(custom_revision_manager.get_registered_models())
+ self.assertEqual(default_registered + custom_registered, len(models))
class SimpleModelTest(BaseTestCase):
@@ -19,9 +19,10 @@
from reversion_compare.helpers import html_diff
from reversion_compare_test_project.reversion_compare_test_app.models import SimpleModel, Factory, Car, Person, Pet,\
- VariantModel
+ VariantModel, CustomModel
from reversion.models import Revision, Version
+from reversion.revisions import RevisionManager
#------------------------------------------------------------------------------
@@ -77,6 +78,13 @@ class VariantModelAdmin(CompareVersionAdmin):
admin.site.register(VariantModel, VariantModelAdmin)
+custom_revision_manager = RevisionManager("custom")
+
+class CustomModelAdmin(CompareVersionAdmin):
+ revision_manager = custom_revision_manager
+admin.site.register(CustomModel, CustomModelAdmin)
+
+
"""
@@ -115,6 +115,11 @@ class VariantModel(models.Model):
#------------------------------------------------------------------------------
+
+class CustomModel(models.Model):
+ "Model which uses a custom version manager."
+ text = models.TextField()
+
"""
class ParentModel(models.Model):

0 comments on commit 8b46986

Please sign in to comment.