def test_quit_process(self): process = TorProcessProtocol(None) process.transport = Mock() d = process.quit() self.assertFalse(d.called) process.processExited(Failure(error.ProcessTerminated(exitCode=15))) self.assertTrue(d.called) process.processEnded(Failure(error.ProcessDone(None))) self.assertTrue(d.called) errs = self.flushLoggedErrors() self.assertEqual(1, len(errs)) self.assertTrue("Tor exited with error-code" in str(errs[0]))
def test_quit_process_already(self): process = TorProcessProtocol(None) process.transport = Mock() def boom(sig): self.assertEqual(sig, 'TERM') raise error.ProcessExitedAlready() process.transport.signalProcess = Mock(side_effect=boom) d = process.quit() process.processEnded(Failure(error.ProcessDone(None))) self.assertTrue(d.called) errs = self.flushLoggedErrors() self.assertEqual(1, len(errs)) self.assertTrue("Tor exited with error-code" in str(errs[0]))
def XXXtest_tor_launch_success_then_shutdown(self): """ There was an error where we double-callbacked a deferred, i.e. success and then shutdown. This repeats it. """ process = TorProcessProtocol(None) process.status_client( 'STATUS_CLIENT BOOTSTRAP PROGRESS=100 TAG=foo SUMMARY=cabbage') # XXX why this assert? self.assertEqual(None, process._connected_cb) class Value(object): exitCode = 123 class Status(object): value = Value() process.processEnded(Status()) self.assertEquals(len(self.flushLoggedErrors(RuntimeError)), 1)