2010-09-13 04:03:39 +08:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
from django.test import TestCase
|
|
|
|
|
2011-10-14 02:04:12 +08:00
|
|
|
from .models import Article
|
2010-09-13 04:03:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
class DefaultTests(TestCase):
|
|
|
|
def test_field_defaults(self):
|
|
|
|
a = Article()
|
|
|
|
now = datetime.now()
|
|
|
|
a.save()
|
|
|
|
|
2016-12-29 23:27:49 +08:00
|
|
|
self.assertIsInstance(a.id, int)
|
2010-09-13 04:03:39 +08:00
|
|
|
self.assertEqual(a.headline, "Default headline")
|
2014-10-28 18:02:56 +08:00
|
|
|
self.assertLess((now - a.pub_date).seconds, 5)
|