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()
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): 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)
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)
def setUp(self): 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