2011-10-14 02:04:12 +08:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2010-09-13 04:03:39 +08:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
from django.test import TestCase
|
2012-07-20 18:45:19 +08:00
|
|
|
from django.utils import six
|
2010-09-13 04:03:39 +08:00
|
|
|
|
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()
|
|
|
|
|
2013-05-21 17:42:15 +08:00
|
|
|
self.assertIsInstance(a.id, six.integer_types)
|
2010-09-13 04:03:39 +08:00
|
|
|
self.assertEqual(a.headline, "Default headline")
|
|
|
|
self.assertTrue((now - a.pub_date).seconds < 5)
|