Anonymous avatar Anonymous committed f50ff2c

remove duplication between StatusModel tests

Comments (0)

Files changed (2)

model_utils/tests/models.py

         ('on_hold', _('on hold')),
     )
 
-class Status2(StatusModel):
+class StatusPlainTuple(StatusModel):
     STATUS = (
         ('active', _('active')),
         ('deleted', _('deleted')),

model_utils/tests/tests.py

 from model_utils import ChoiceEnum, Choices
 from model_utils.fields import get_excerpt
 from model_utils.tests.models import InheritParent, InheritChild, TimeStamp, \
-    Post, Article, Status, Status2, TimeFrame, Monitored
+    Post, Article, Status, StatusPlainTuple, TimeFrame, Monitored
 
 
 class GetExcerptTests(TestCase):
 class StatusModelTests(TestCase):
     def setUp(self):
         self.model = Status
+        self.on_hold = Status.STATUS.on_hold
+        self.active = Status.STATUS.active
 
     def test_created(self):
         c1 = self.model.objects.create()
     def test_modification(self):
         t1 = self.model.objects.create()
         date_created = t1.status_changed
-        t1.status = t1.STATUS.on_hold
+        t1.status = self.on_hold
         t1.save()
         self.assertEquals(self.model.active.count(), 0)
         self.assertEquals(self.model.on_hold.count(), 1)
         t1.save()
         self.assertEquals(t1.status_changed, date_changed)
         date_active_again = t1.status_changed
-        t1.status = t1.STATUS.active
+        t1.status = self.active
         t1.save()
         self.assert_(t1.status_changed > date_active_again)
 
         
-class Status2ModelTests(StatusModelTests):
+class StatusModelPlainTupleTests(StatusModelTests):
     def setUp(self):
-        self.model = Status2
-
-    def test_modification(self):
-        t1 = self.model.objects.create()
-        date_created = t1.status_changed
-        t1.status = t1.STATUS[2][0] # boring on_hold status
-        t1.save()
-        self.assertEquals(self.model.active.count(), 0)
-        self.assertEquals(self.model.on_hold.count(), 1)
-        self.assert_(t1.status_changed > date_created)
-        date_changed = t1.status_changed
-        t1.save()
-        self.assertEquals(t1.status_changed, date_changed)
-        date_active_again = t1.status_changed
-        t1.status = t1.STATUS[0][0] # boring active status
-        t1.save()
-        self.assert_(t1.status_changed > date_active_again)
+        self.model = StatusPlainTuple
+        self.on_hold = StatusPlainTuple.STATUS[2][0]
+        self.active = StatusPlainTuple.STATUS[0][0]
 
 
 class QueryManagerTests(TestCase):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.