/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-02-28 22:17:56 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 382.
  • Revision ID: teddy@recompile.se-20190228221756-qd6ynzhzatmp2g6a
mandos-ctl: Add more tests

* mandos-ctl (string_to_delta): Add some basic tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
557
557
        self.assertEqual(milliseconds_to_string(900), "00:00:00")
558
558
        self.assertEqual(milliseconds_to_string(1900), "00:00:01")
559
559
 
 
560
class Test_string_to_delta(unittest.TestCase):
 
561
    def test_handles_basic_rfc3339(self):
 
562
        self.assertEqual(string_to_delta("PT2H"),
 
563
                         datetime.timedelta(0, 7200))
 
564
    def test_falls_back_to_pre_1_6_1_with_warning(self):
 
565
        # assertLogs only exists in Python 3.4
 
566
        if hasattr(self, "assertLogs"):
 
567
            with self.assertLogs(log, logging.WARNING):
 
568
                value = string_to_delta("2h")
 
569
        else:
 
570
            value = string_to_delta("2h")
 
571
        self.assertEqual(value, datetime.timedelta(0, 7200))
 
572
 
560
573
 
561
574
def should_only_run_tests():
562
575
    parser = argparse.ArgumentParser(add_help=False)