574
574
value = string_to_delta("2h")
575
575
self.assertEqual(value, datetime.timedelta(0, 7200))
577
class Test_table_rows_of_clients(unittest.TestCase):
580
self.old_tablewords = tablewords
585
"Bool": "A D-BUS Boolean",
586
"NonDbusBoolean": "A Non-D-BUS Boolean",
587
"Integer": "An Integer",
588
"Timeout": "Timedelta 1",
589
"Interval": "Timedelta 2",
590
"ApprovalDelay": "Timedelta 3",
591
"ApprovalDuration": "Timedelta 4",
592
"ExtendedTimeout": "Timedelta 5",
593
"String": "A String",
595
self.keywords = ["Attr1", "AttrTwo"]
601
"Bool": dbus.Boolean(False),
602
"NonDbusBoolean": False,
606
"ApprovalDelay": 2000,
607
"ApprovalDuration": 3000,
608
"ExtendedTimeout": 4000,
615
"Bool": dbus.Boolean(True),
616
"NonDbusBoolean": True,
619
"Interval": 93786000,
620
"ApprovalDelay": 93787000,
621
"ApprovalDuration": 93788000,
622
"ExtendedTimeout": 93789000,
623
"String": "A huge string which will not fit," * 10,
628
tablewords = self.old_tablewords
629
def test_short_header(self):
630
rows = table_rows_of_clients(self.clients, self.keywords)
635
self.assertEqual(rows, expected_rows)
636
def test_booleans(self):
637
keywords = ["Bool", "NonDbusBoolean"]
638
rows = table_rows_of_clients(self.clients, keywords)
640
"A D-BUS Boolean A Non-D-BUS Boolean",
644
self.assertEqual(rows, expected_rows)
645
def test_milliseconds_detection(self):
646
keywords = ["Integer", "Timeout", "Interval", "ApprovalDelay",
647
"ApprovalDuration", "ExtendedTimeout"]
648
rows = table_rows_of_clients(self.clients, keywords)
650
An Integer Timedelta 1 Timedelta 2 Timedelta 3 Timedelta 4 Timedelta 5
651
0 00:00:00 00:00:01 00:00:02 00:00:03 00:00:04
652
1 1T02:03:05 1T02:03:06 1T02:03:07 1T02:03:08 1T02:03:09
655
self.assertEqual(rows, expected_rows)
656
def test_empty_and_long_string_values(self):
657
keywords = ["String"]
658
rows = table_rows_of_clients(self.clients, keywords)
662
A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,
665
self.assertEqual(rows, expected_rows)
578
669
def should_only_run_tests():
579
670
parser = argparse.ArgumentParser(add_help=False)