def test_switchTo(self): """ L{ShellServer.switchTo} takes a L{ITerminalServerFactory} and uses it to create a new L{ITerminalProtocol} which it connects to a L{_ReturnToMenuWrapper}. L{buildTerminalProtocol} is passed an L{IViewer}. """ terminal = FakeTerminal() store = Store() # Put a login method into the store so it can have a role. See #2665. LoginMethod( store=store, internal=True, protocol=u'*', verified=True, localpart=u'alice', domain=u'example.com', # Not really an account, but simpler... account=store) server = ShellServer(store) server.makeConnection(terminal) factory = MockTerminalServerFactory() server.switchTo(factory) self.assertIdentical(factory.shellViewer.roleIn(store), getSelfRole(store)) self.assertTrue(isinstance(server._protocol, MockTerminalProtocol)) self.assertTrue( isinstance(server._protocol.terminal, _ReturnToMenuWrapper)) self.assertIdentical(server._protocol.terminal._shell, server) self.assertIdentical(server._protocol.terminal._terminal, terminal)
def test_reactivate(self): """ L{ShellServer.reactivate} disconnects the protocol previously switched to, drops the reference to it, and redraws the main menu. """ terminal = FakeTerminal() server = ShellServer(Store()) server.makeConnection(terminal) server.switchTo(MockTerminalServerFactory()) server.reactivate() self.assertIdentical(server._protocol, None)
def test_reactivate(self): """ L{ShellServer.reactivate} disconnects the protocol previously switched to, drops the reference to it, and redraws the main menu. """ terminal = FakeTerminal() server = ShellServer(Store()) server.makeConnection(terminal) server.switchTo(MockTerminalServerFactory()) server.reactivate() self.assertIdentical(server._protocol, None)
def test_keystrokeReceivedProtocol(self): """ L{ShellServer.keystrokeReceived} delivers keystroke data to the protocol built by the factory which has been switched to. """ factory = MockTerminalServerFactory() terminal = FakeTerminal() server = ShellServer(Store()) server.makeConnection(terminal) server.switchTo(factory) server.keystrokeReceived(' ', ServerProtocol.ALT) self.assertEqual(factory.terminalProtocolInstance.keystrokes, [(' ', ServerProtocol.ALT)])
def test_keystrokeReceivedProtocol(self): """ L{ShellServer.keystrokeReceived} delivers keystroke data to the protocol built by the factory which has been switched to. """ factory = MockTerminalServerFactory() terminal = FakeTerminal() server = ShellServer(Store()) server.makeConnection(terminal) server.switchTo(factory) server.keystrokeReceived(' ', ServerProtocol.ALT) self.assertEqual( factory.terminalProtocolInstance.keystrokes, [(' ', ServerProtocol.ALT)])
def test_switchTo(self): """ L{ShellServer.switchTo} takes a L{ITerminalServerFactory} and uses it to create a new L{ITerminalProtocol} which it connects to a L{_ReturnToMenuWrapper}. L{buildTerminalProtocol} is passed an L{IViewer}. """ terminal = FakeTerminal() store = Store() # Put a login method into the store so it can have a role. See #2665. LoginMethod( store=store, internal=True, protocol=u'*', verified=True, localpart=u'alice', domain=u'example.com', # Not really an account, but simpler... account=store) server = ShellServer(store) server.makeConnection(terminal) factory = MockTerminalServerFactory() server.switchTo(factory) self.assertIdentical(factory.shellViewer.roleIn(store), getSelfRole(store)) self.assertTrue(isinstance(server._protocol, MockTerminalProtocol)) self.assertTrue(isinstance(server._protocol.terminal, _ReturnToMenuWrapper)) self.assertIdentical(server._protocol.terminal._shell, server) self.assertIdentical(server._protocol.terminal._terminal, terminal)