Example #1
0
    def test_replicating_port_array_results_in_array_with_disconnected_ports(self):
        self.ports.add_port('hello')
        self.ports.add_port('world')
        self.ports.connect_port('hello', lambda: None)

        new_ports = PortArray.replicate(self.ports)
        self.assertIsNot(new_ports, self.ports)
        self.assertItemsEqual(['hello', 'world'], new_ports.get_ports())

        # all ports should be disconnected
        with self.assertRaisesRegexp(DisconnectedPort, 'Port "hello" has not been connected'):
            new_ports.hello()
        with self.assertRaisesRegexp(DisconnectedPort, 'Port "world" has not been connected'):
            new_ports.world()
Example #2
0
 def __init__(self):
     super(Service, self).__init__()
     self.deps = PortArray.replicate(
         self.__class__.deps
     )  # each service instance should have its own copy