Ejemplo n.º 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()
Ejemplo n.º 2
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.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)
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()
Ejemplo n.º 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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
 def setUp(self):
     self.instance = Monitored(name='Charlie')
     self.created = self.instance.name_changed
Ejemplo n.º 7
0
 def setUp(self):
     self.instance = Monitored(name='Charlie')
     self.created = self.instance.name_changed
Ejemplo n.º 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
 def setUp(self):
     with freeze_time(datetime(2016, 1, 1, 10, 0, 0)):
         self.instance = Monitored(name='Charlie')
         self.created = self.instance.name_changed