/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-13 21:38:35 UTC
  • mto: This revision was merged to the branch mainline in revision 382.
  • Revision ID: teddy@recompile.se-20190313213835-vq9cv3lih2jp3au7
mandos-ctl: Refactor

* mandos-ctl (TestCmd.bus.Bus.get_object): Add explanatory comment
                                           about "self".
  (Unique): Move to "TestPropertyCmd.Unique".  All callers changed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1269
1269
            def get_object(client_bus_name, path):
1270
1270
                self.assertEqual(client_bus_name, dbus_busname)
1271
1271
                return {
 
1272
                    # Note: "self" here is the TestCmd instance, not
 
1273
                    # the Bus instance, since this is a static method!
1272
1274
                    "/clients/foo": self.client,
1273
1275
                    "/clients/barbar": self.other_client,
1274
1276
                }[path]
1513
1515
        self.assertEqual(output, expected_output)
1514
1516
 
1515
1517
 
1516
 
class Unique(object):
1517
 
    """Class for objects which exist only to be unique objects, since
1518
 
unittest.mock.sentinel only exists in Python 3.3"""
1519
 
 
1520
 
 
1521
1518
class TestPropertyCmd(TestCmd):
1522
1519
    """Abstract class for tests of PropertyCmd classes"""
1523
1520
    def runTest(self):
1530
1527
            for clientpath in self.clients:
1531
1528
                client = self.bus.get_object(dbus_busname, clientpath)
1532
1529
                old_value = client.attributes[self.propname]
1533
 
                self.assertNotIsInstance(old_value, Unique)
1534
 
                client.attributes[self.propname] = Unique()
 
1530
                self.assertNotIsInstance(old_value, self.Unique)
 
1531
                client.attributes[self.propname] = self.Unique()
1535
1532
            self.run_command(value_to_set, self.clients)
1536
1533
            for clientpath in self.clients:
1537
1534
                client = self.bus.get_object(dbus_busname, clientpath)
1538
1535
                value = client.attributes[self.propname]
1539
 
                self.assertNotIsInstance(value, Unique)
 
1536
                self.assertNotIsInstance(value, self.Unique)
1540
1537
                self.assertEqual(value, value_to_get)
 
1538
 
 
1539
    class Unique(object):
 
1540
        """Class for objects which exist only to be unique objects,
 
1541
since unittest.mock.sentinel only exists in Python 3.3"""
 
1542
 
1541
1543
    def run_command(self, value, clients):
1542
1544
        self.command().run(clients, self.bus)
1543
1545