def test_multiple_transport(self): """Create multiple servers on the same host""" # Get the hostname import platform host = platform.node() self.assertNotEqual(0, len(host)) fbt1 = FlowBuilderTransport(host, host) fbt2 = FlowBuilderTransport(host, host) fbt2.shutdown() fbt1.shutdown()
def test_multiple_flowbuilder(self): """Create multiple servers on the same host""" # Get the hostname import platform host = platform.node() self.assertNotEqual(0, len(host)) fbt1 = FlowBuilderTransport(host, host) fb1 = fbt1.getFlowBuilder() fbt2 = FlowBuilderTransport(host, host) fb2 = fbt2.getFlowBuilder() self.assertEqual(True, fb1.isReady()) self.assertEqual(True, fb2.isReady()) self.assertRaises(Pyro4.errors.ConnectionClosedError, fb1.shutdown) self.assertRaises(Pyro4.errors.ConnectionClosedError, fb2.shutdown)
def test_multiple_transport_detailed(self): """Create multiple servers on the same host""" # Get the hostname import platform host = platform.node() self.assertNotEqual(0, len(host)) fbt1 = FlowBuilderTransport(host, host) fbt2 = FlowBuilderTransport(host, host) # Now test that a message can cross the transports host1 = fbt1.getFlowBuilder().hostname() host2 = fbt2.getFlowBuilder().hostname() self.assertEqual(host1, host2) # Shutdown cleanly fbt2.shutdown() fbt1.shutdown()
def test_invalid_host(self): """Test construction with an invalid hostname""" try: f = FlowBuilderTransport('invalid-hostip-string', 'invalid-hostname-string') self.assertEqual(True, False) except FlowBuilderTransportError: self.assertEqual(True, True) except: self.assertEqual(True, False)
def test_single_flowbuilder(self): """Create a single server on a host""" # Get the hostname import platform host = platform.node() self.assertNotEqual(0, len(host)) fbt = FlowBuilderTransport(host, host) fb = fbt.getFlowBuilder() self.assertEqual(True, fb.isReady()) self.assertRaises(Pyro4.errors.ConnectionClosedError, fb.shutdown)
def test_valid_host(self): """Test construction with a legal hostname""" # Get the hostname import platform host = platform.node() self.assertNotEqual(0, len(host)) try: f = FlowBuilderTransport(host, host) self.assertEqual(True, True) except: self.assertEqual(False, True)
def buildEndpoint(self, flowSpec): """Create an individual endpoint""" b = None hostIP = flowSpec['ip'] hostname = flowSpec['hostname'] if 'localhost' == hostIP: b = FlowBuilder() else: # Build a remote transport try: trans = FlowBuilderTransport(hostIP, hostname) self.remoteTransports.append(trans) # Extract the flow builder proxy from the transport b = trans.getFlowBuilder() except FlowBuilderTransportError: raise EndpointCreationError() return b