예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)])
예제 #5
0
 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)])
예제 #6
0
 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)