/mandos/trunk

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

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-03-17 11:19:58 UTC
  • Revision ID: teddy@recompile.se-20190317111958-vpq5pvd70hdijadj
mandos-ctl: Refactor

* mandos-ctl (TestBaseCommands): Rename test methods to match names of
                                 tested command.
  (TestBaseCommands.test_is_enabled): Rename to "test_IsEnabled".
  (TestBaseCommands.test_is_enabled_run_exits_successfully): Rename to
                              "test_IsEnabled_run_exits_successfully".
  (TestBaseCommands.test_is_enabled_run_exits_with_failure): Rename to
                              "test_IsEnabled_run_exits_with_failure".
  (TestBaseCommands.test_approve): Rename to "test_Approve".
  (TestBaseCommands.test_deny): Rename to "test_Deny".
  (TestBaseCommands.test_remove): Rename to "test_Remove".

Show diffs side-by-side

added added

removed removed

Lines of Context:
1458
1458
 
1459
1459
class TestBaseCommands(TestCommand):
1460
1460
 
1461
 
    def test_is_enabled(self):
 
1461
    def test_IsEnabled(self):
1462
1462
        self.assertTrue(all(command.IsEnabled().is_enabled(client,
1463
1463
                                                      properties)
1464
1464
                            for client, properties
1465
1465
                            in self.clients.items()))
1466
1466
 
1467
 
    def test_is_enabled_run_exits_successfully(self):
 
1467
    def test_IsEnabled_run_exits_successfully(self):
1468
1468
        with self.assertRaises(SystemExit) as e:
1469
1469
            command.IsEnabled().run(self.one_client)
1470
1470
        if e.exception.code is not None:
1472
1472
        else:
1473
1473
            self.assertIsNone(e.exception.code)
1474
1474
 
1475
 
    def test_is_enabled_run_exits_with_failure(self):
 
1475
    def test_IsEnabled_run_exits_with_failure(self):
1476
1476
        self.client.attributes["Enabled"] = dbus.Boolean(False)
1477
1477
        with self.assertRaises(SystemExit) as e:
1478
1478
            command.IsEnabled().run(self.one_client)
1481
1481
        else:
1482
1482
            self.assertIsNotNone(e.exception.code)
1483
1483
 
1484
 
    def test_approve(self):
 
1484
    def test_Approve(self):
1485
1485
        command.Approve().run(self.clients, self.bus)
1486
1486
        for clientpath in self.clients:
1487
1487
            client = self.bus.get_object(dbus_busname, clientpath)
1488
1488
            self.assertIn(("Approve", (True, client_dbus_interface)),
1489
1489
                          client.calls)
1490
1490
 
1491
 
    def test_deny(self):
 
1491
    def test_Deny(self):
1492
1492
        command.Deny().run(self.clients, self.bus)
1493
1493
        for clientpath in self.clients:
1494
1494
            client = self.bus.get_object(dbus_busname, clientpath)
1495
1495
            self.assertIn(("Approve", (False, client_dbus_interface)),
1496
1496
                          client.calls)
1497
1497
 
1498
 
    def test_remove(self):
 
1498
    def test_Remove(self):
1499
1499
        class MockMandos(object):
1500
1500
            def __init__(self):
1501
1501
                self.calls = []