/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-03-17 16:48:56 UTC
  • mto: This revision was merged to the branch mainline in revision 382.
  • Revision ID: teddy@recompile.se-20190317164856-de11glvsfwhnj34w
mandos-ctl: Refactor tests

* mandos-ctl (Test_string_to_delta.test_handles_basic_rfc3339): Split
                                                  into multiple tests.
  (Test_string_to_delta.test_rfc3339_zero_seconds): New.
  (Test_string_to_delta.test_rfc3339_zero_days): - '' -
  (Test_string_to_delta.test_rfc3339_one_second): - '' -
  (Test_string_to_delta.test_rfc3339_two_hours): - '' -
  (TestCommand.setUp.MockClient.Get): Remove; unused.
  (TestBaseCommands.test_Remove): Remove unnecessary assertion.
  (TestPropertyCmd.runTest): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
886
886
 
887
887
 
888
888
class Test_string_to_delta(TestCaseWithAssertLogs):
889
 
    def test_handles_basic_rfc3339(self):
 
889
    # Just test basic RFC 3339 functionality here, the doc string for
 
890
    # rfc3339_duration_to_delta() already has more comprehensive
 
891
    # tests, which is run by doctest.
 
892
 
 
893
    def test_rfc3339_zero_seconds(self):
890
894
        self.assertEqual(string_to_delta("PT0S"),
891
895
                         datetime.timedelta())
 
896
 
 
897
    def test_rfc3339_zero_days(self):
892
898
        self.assertEqual(string_to_delta("P0D"),
893
899
                         datetime.timedelta())
 
900
 
 
901
    def test_rfc3339_one_second(self):
894
902
        self.assertEqual(string_to_delta("PT1S"),
895
903
                         datetime.timedelta(0, 1))
 
904
 
 
905
    def test_rfc3339_two_hours(self):
896
906
        self.assertEqual(string_to_delta("PT2H"),
897
907
                         datetime.timedelta(0, 7200))
898
908
 
1376
1386
                testcase.assertEqual(dbus_interface,
1377
1387
                                     dbus.PROPERTIES_IFACE)
1378
1388
                self.attributes[propname] = value
1379
 
            def Get(self, interface, propname, dbus_interface):
1380
 
                testcase.assertEqual(interface, client_dbus_interface)
1381
 
                testcase.assertEqual(dbus_interface,
1382
 
                                     dbus.PROPERTIES_IFACE)
1383
 
                return self.attributes[propname]
1384
1389
            def Approve(self, approve, dbus_interface):
1385
1390
                testcase.assertEqual(dbus_interface,
1386
1391
                                     client_dbus_interface)
1503
1508
                self.calls.append(("RemoveClient", (dbus_path,)))
1504
1509
        mandos = MockMandos()
1505
1510
        command.Remove().run(self.clients, self.bus, mandos)
1506
 
        self.assertEqual(len(mandos.calls), 2)
1507
1511
        for clientpath in self.clients:
1508
1512
            self.assertIn(("RemoveClient", (clientpath,)),
1509
1513
                          mandos.calls)
1695
1699
            for clientpath in self.clients:
1696
1700
                client = self.bus.get_object(dbus_busname, clientpath)
1697
1701
                old_value = client.attributes[self.propname]
1698
 
                self.assertNotIsInstance(old_value, self.Unique)
1699
1702
                client.attributes[self.propname] = self.Unique()
1700
1703
            self.run_command(value_to_set, self.clients)
1701
1704
            for clientpath in self.clients: