def test_commandlog_simple_model(self): inst = CommandLog() inst.save() self.assertIsNotNone(inst.uuid) self.assertIsNotNone(inst.command_name) self.assertIsNotNone(inst.start_at) self.assertIsNone(inst.end_at) self.assertIsNone(inst.success) self.assertEqual(inst.created, 0) self.assertEqual(inst.read, 0) self.assertEqual(inst.updated, 0) self.assertEqual(inst.deleted, 0) self.assertEqual(inst.errors, 0) self.assertEqual(inst.get_total_crud(), 0)
def setUp(self): self.site = AdminSite() self.cmdlog = CommandLog() self.cmdlog.save() self.cmdlog.start_at = make_aware( datetime.datetime(year=2016, month=2, day=2, hour=13, minute=37, second=42)) self.cmdlog.end_at = self.cmdlog.start_at + datetime.timedelta(days=1) self.cmdlog.created = 42 self.cmdlog.deleted = 21 self.cmdlog.save()
def test_commandlog_model_str_output_complete(self): inst = CommandLog() inst.save() inst.command_name = self.__class__.__name__ inst.imported_by_str = "Test User" start_at_str = datetime.datetime.strftime(inst.start_at, '%Y-%m-%d %H:%M:%S') self.assertEqual(str(inst), self.__class__.__name__ + " at " + start_at_str + " by Test User")
def test_commandlog_model_str_output_complete_with_user(self): u = User.objects.create(username="******", email="*****@*****.**") inst = CommandLog() inst.save() inst.command_name = self.__class__.__name__ inst.imported_by_user = u start_at_str = datetime.datetime.strftime(inst.start_at, '%Y-%m-%d %H:%M:%S') self.assertEqual(str(inst), self.__class__.__name__ + " at " + start_at_str + " by test")
class CommandLogAdminTestCase(TestCase): def setUp(self): self.site = AdminSite() self.cmdlog = CommandLog() self.cmdlog.save() self.cmdlog.start_at = make_aware( datetime.datetime(year=2016, month=2, day=2, hour=13, minute=37, second=42)) self.cmdlog.end_at = self.cmdlog.start_at + datetime.timedelta(days=1) self.cmdlog.created = 42 self.cmdlog.deleted = 21 self.cmdlog.save() def test_log_admin_duration(self): self.assertEqual(CommandLogAdmin.duration(self.cmdlog), datetime.timedelta(days=1)) def test_log_admin_total_crud(self): self.assertEqual(CommandLogAdmin.total_crud(self.cmdlog), 63)
def test_commandlog_model_duration_empty(self): inst = CommandLog() inst.save() self.assertEqual(inst.get_duration(), datetime.timedelta())
def test_commandlog_model_duration_calculation(self): inst = CommandLog() inst.start_at = datetime.datetime(year=2016, month=2, day=2, hour=13, minute=37, second=42) inst.end_at = inst.start_at + datetime.timedelta(days=1) self.assertEqual(inst.get_duration(), datetime.timedelta(days=1))
def test_commandlog_model_str_output_simple(self): inst = CommandLog() inst.save() start_at_str = datetime.datetime.strftime(inst.start_at, '%Y-%m-%d %H:%M:%S') self.assertEqual(str(inst), " at " + start_at_str + "")