def test_is_already_running(self): """The is_already_running method returns True if already started.""" server = self.get_server() self.addCleanup(server.clean_up) class TestConnect(object): """A fake connection object.""" @defer.inlineCallbacks def connect(my_self, factory): """A fake connection.""" conn_fact = yield server.connect_client(PortDetectFactory) self.patch(factory, 'is_listening', conn_fact.is_listening) defer.returnValue(conn_fact) self.patch( tcpactivation, 'clientFromString', lambda *args: TestConnect()) yield server.listen_server(protocol.ServerFactory) ad = ActivationDetector(self.config) result = yield ad.is_already_running() self.assertTrue(result, "It should be already running.")
def test_is_not_already_running(self): """Test the is_already_running method returns False.""" ad = ActivationDetector(self.config) result = yield ad.is_already_running() self.assertFalse(result, "It should not be already running.")