Commits

Anonymous committed d501b82

Upped coverage

Comments (0)

Files changed (3)

tests/testproject/admin.py

 from django.contrib import admin
 from models import TimestampedItem, FakeTimestampedItem,\
-    AlternativeTimestampedItem, SingleTimestampedItem
+    AlternativeTimestampedItem, SingleTimestampedItem, DateStampedItem
 from admintimestamps import TimestampedAdminMixin
 
 
 admin.site.register(SingleTimestampedItem, SingleTimestampedAdmin)
 
 
+class DateStampedAdmin(TimestampedAdminMixin, admin.ModelAdmin):
+    pass
+
+admin.site.register(DateStampedItem, DateStampedAdmin)
+
+
 class AlternativeTimestampedAdmin(TimestampedAdmin):
     timestamp_fields = ('created_at', 'modified_at')
 

tests/testproject/models.py

         return self.title
 
 
+class DateStampedItem(models.Model):
+    title = models.CharField('title', max_length=100)
+    created = models.DateField('created', auto_now_add=True)
+    modified = models.DateTimeField('modified', auto_now=True)
+
+    def __unicode__(self):
+        return self.title
+
+
 class FakeTimestampedItem(models.Model):
     '''
     This model doesn't actually set it's timestamps, makes it easier

tests/testproject/tests.py

 from django import test
 from django.contrib.auth.models import User
 from models import AlternativeTimestampedItem, FakeTimestampedItem, \
-    SingleTimestampedItem
+    SingleTimestampedItem, DateStampedItem
 
 
 class TestAdmin(test.TestCase):
                             modified=datetime(2011, 5, 28, 9, 59)).save()
         AlternativeTimestampedItem(title='alternative').save()
         SingleTimestampedItem(title='single timestamp').save()
+        DateStampedItem(title='datestamp').save()
         user = User.objects.create_user('test', 'test@example.com', 'test')
         user.is_staff = user.is_superuser = True
         user.save()
         self.assertRegexpMatches(response.content,
                                  r'Modified at\s*</a></(?:th|div)>')
 
-    def test_asingle_header_row(self):
+    def test_single_header_row(self):
         response = self.client.get(
                      '/admin/testproject/singletimestampeditem/')
         self.assertRegexpMatches(response.content,
                                  r'Modified\s*</a></(?:th|div)>')
+
+    def test_datestamp_header_row(self):
+        response = self.client.get(
+                     '/admin/testproject/datestampeditem/')
+        self.assertRegexpMatches(response.content,
+                                 r'Created\s*</a></(?:th|div)>')
+        self.assertRegexpMatches(response.content,
+                                 r'Modified\s*</a></(?:th|div)>')