コード例 #1
0
class MonitorFieldTests(TestCase):
    def setUp(self):
        with freeze_time(datetime(2016, 1, 1, 10, 0, 0)):
            self.instance = Monitored(name='Charlie')
            self.created = self.instance.name_changed

    def test_save_no_change(self):
        self.instance.save()
        self.assertEqual(self.instance.name_changed, self.created)

    def test_save_changed(self):
        with freeze_time(datetime(2016, 1, 1, 12, 0, 0)):
            self.instance.name = 'Maria'
            self.instance.save()
        self.assertEqual(self.instance.name_changed, datetime(2016, 1, 1, 12, 0, 0))

    def test_double_save(self):
        self.instance.name = 'Jose'
        self.instance.save()
        changed = self.instance.name_changed
        self.instance.save()
        self.assertEqual(self.instance.name_changed, changed)

    def test_no_monitor_arg(self):
        with self.assertRaises(TypeError):
            MonitorField()
コード例 #2
0
ファイル: tests.py プロジェクト: DXist/django-model-utils
class MonitorFieldTests(TestCase):
    def setUp(self):
        self.instance = Monitored(name='Charlie')
        self.created = self.instance.name_changed


    def test_save_no_change(self):
        self.instance.save()
        self.assertEquals(self.instance.name_changed, self.created)


    def test_save_changed(self):
        self.instance.name = 'Maria'
        self.instance.save()
        self.failUnless(self.instance.name_changed > self.created)


    def test_double_save(self):
        self.instance.name = 'Jose'
        self.instance.save()
        changed = self.instance.name_changed
        self.instance.save()
        self.assertEquals(self.instance.name_changed, changed)


    def test_no_monitor_arg(self):
        self.assertRaises(TypeError, MonitorField)
コード例 #3
0
class MonitorFieldTests(TestCase):
    def setUp(self):
        with freeze_time(datetime(2016, 1, 1, 10, 0, 0)):
            self.instance = Monitored(name='Charlie')
            self.created = self.instance.name_changed

    def test_save_no_change(self):
        self.instance.save()
        self.assertEqual(self.instance.name_changed, self.created)

    def test_save_changed(self):
        with freeze_time(datetime(2016, 1, 1, 12, 0, 0)):
            self.instance.name = 'Maria'
            self.instance.save()
        self.assertEqual(self.instance.name_changed,
                         datetime(2016, 1, 1, 12, 0, 0))

    def test_double_save(self):
        self.instance.name = 'Jose'
        self.instance.save()
        changed = self.instance.name_changed
        self.instance.save()
        self.assertEqual(self.instance.name_changed, changed)

    def test_no_monitor_arg(self):
        with self.assertRaises(TypeError):
            MonitorField()
コード例 #4
0
class MonitorFieldTests(TestCase):
    def setUp(self):
        self.instance = Monitored(name='Charlie')
        self.created = self.instance.name_changed


    def test_save_no_change(self):
        self.instance.save()
        self.assertEqual(self.instance.name_changed, self.created)


    def test_save_changed(self):
        self.instance.name = 'Maria'
        self.instance.save()
        self.assertTrue(self.instance.name_changed > self.created)


    def test_double_save(self):
        self.instance.name = 'Jose'
        self.instance.save()
        changed = self.instance.name_changed
        self.instance.save()
        self.assertEqual(self.instance.name_changed, changed)


    def test_no_monitor_arg(self):
        self.assertRaises(TypeError, MonitorField)
コード例 #5
0
ファイル: tests.py プロジェクト: rafaduran/django-model-utils
class MonitorFieldTests(TestCase):
    def setUp(self):
        self.instance = Monitored(name="Charlie")
        self.created = self.instance.name_changed

    def test_save_no_change(self):
        self.instance.save()
        self.assertEqual(self.instance.name_changed, self.created)

    def test_save_changed(self):
        self.instance.name = "Maria"
        self.instance.save()
        self.assertTrue(self.instance.name_changed > self.created)

    def test_double_save(self):
        self.instance.name = "Jose"
        self.instance.save()
        changed = self.instance.name_changed
        self.instance.save()
        self.assertEqual(self.instance.name_changed, changed)

    def test_no_monitor_arg(self):
        self.assertRaises(TypeError, MonitorField)
コード例 #6
0
 def setUp(self):
     self.instance = Monitored(name='Charlie')
     self.created = self.instance.name_changed
コード例 #7
0
ファイル: tests.py プロジェクト: DXist/django-model-utils
 def setUp(self):
     self.instance = Monitored(name='Charlie')
     self.created = self.instance.name_changed
コード例 #8
0
 def setUp(self):
     with freeze_time(datetime(2016, 1, 1, 10, 0, 0)):
         self.instance = Monitored(name='Charlie')
         self.created = self.instance.name_changed
コード例 #9
0
 def setUp(self):
     with freeze_time(datetime(2016, 1, 1, 10, 0, 0)):
         self.instance = Monitored(name='Charlie')
         self.created = self.instance.name_changed