def test_connectionLost_sends_connection_closed_to_the_outputs(): f = TelnetClientFactory(None, 'ascii', None) telnet = TelnetClient(f) r = f.realm = Mock(spec = RootRealm) telnet.connectionLost(None) assert r.connectionLost.called
class Test_LineReceiver_aspects: def setUp(self): self.received = [] self.tc = TelnetClient(TelnetClientFactory(None, 'ascii', None)) self.tc.transport = FakeTransport() self.tc.lineReceived = self.lr def lr(self, line): self.received.append(line) def test_boring(self): self.tc.dataReceived("foo\r\nbar\r\nbaz") assert self.received == ['foo', 'bar'], self.received def test_closing_flushes_buffer(self): self.tc.dataReceived("bar") self.tc.connectionLost(None) assert self.received == ['bar']