Esempio 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
Esempio n. 2
0
class Test_server_echo_setting:

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

    def test_allows_enabling(self):
        res = self.tc.enableRemote(ECHO)
        assert res

    def test_enable_sets_server_echo_to_True(self):
        self.tc.enableRemote(ECHO)
        assert self.f.realm.server_echo

    def test_enable_hides_input_box_but_grabs_focus(self):
        self.tc.enableRemote(ECHO)
        assert self.f.gui.command_line.method_calls == \
               [('set_visibility', (False,), {})]

    def test_disable_sets_server_echo_to_False(self):
        self.tc.enableRemote(ECHO)
        self.tc.disableRemote(ECHO)
        assert not self.f.realm.server_echo

    def test_disable_shows_input_box_and_grabs_focus(self):
        self.tc.disableRemote(ECHO)
        assert self.f.gui.command_line.method_calls == \
               [('set_visibility', (True,), {})]