Ejemplo n.º 1
0
class Test_MCCP:

    def setUp(self):
        self.tc = TelnetClient(TelnetClientFactory(None, 'ascii', None))
        self.tc.transport = self.t = FakeTransport()

    def test_agree_to_enable_COMPRESS2(self):
        assert self.tc.enableRemote(COMPRESS2)

    def test_doesnt_agree_to_random_nexed_options(self):
        assert not self.tc.enableRemote('\xA2')

    def test_doesnt_enable_MCCP_without_COMPRESS2(self):
        self.tc.negotiationMap[COMPRESS2]('')
        assert not self.t.their_mccp_active

    def test_does_enable_MCCP_with_COMPRESS2(self):
        self.tc.enableRemote(COMPRESS2)
        self.tc.negotiationMap[COMPRESS2]('')
        assert self.t.their_mccp_active

    def test_enable_disable_leaves_disabled(self):
        self.tc.enableRemote(COMPRESS2)
        self.tc.disableRemote(COMPRESS2)
        self.tc.negotiationMap[COMPRESS2]('')
        assert not self.t.their_mccp_active

    def test_close_loses_connection(self):
        self.tc.close()
        assert self.t.lost_connection