예제 #1
0
 def setUp(self):
     self.factory = TelnetClientFactory(None, 'ascii', None)
     self.factory.gui = Mock(spec = GUI,
                             #instance variables
                             methods = ['output_window', 'command_line'])
     self.factory.output_window = Mock(spec = CommandView)
     self.factory.command_line = Mock(spec = OutputView)
예제 #2
0
 def setUp(self):
     self.f = TelnetClientFactory(None, 'ascii', None)
     self.f.realm = self.e = Mock(spec=RootRealm)
     self.tc = TelnetClient(self.f)
     self.tc.transport = FakeTransport()
     self.fores = RunLengthList([(0, fg_code(WHITE, False))])
     self.backs = RunLengthList([(0, bg_code(BLACK))])
예제 #3
0
 def setUp(self):
     self.time = Mock(methods=['strftime'])
     self.time.strftime.return_value = "FOO %(name)s"
     self.factory = TelnetClientFactory('baz', None, None)
     self.realm = self.factory.realm
     self.open = Mock()
     self.open.return_value = MockFile()
예제 #4
0
def main():
    """Launch the client.

    This is the main entry point. This will first initialise the GUI, then
    load the main module specified on the command line.
    """
    options = parser.parse_args()

    modclass = load_file(options.modulename)
    factory = TelnetClientFactory(modclass.name, modclass.encoding,
                                  options.modulename)

    if options.gui == 'gtk':
        from mudpyl.gui.gtkgui import configure

    configure(factory)

    modinstance = factory.realm.load_module(modclass)
    modinstance.is_main(factory.realm)

    from twisted.internet import reactor

    #pylint kicks up a major fuss about these lines, but that's because
    #Twisted does some hackery with the reactor namespace.
    #pylint: disable-msg=E1101

    reactor.connectTCP(modclass.host, modclass.port, factory)
    if not options.profile:
        reactor.run()
    else:
        import cProfile
        cProfile.runctx("reactor.run()",
                        globals(),
                        locals(),
                        filename="mudpyl.prof")
예제 #5
0
def test_connectionMade_sends_connection_opened_to_the_outputs():
    f = TelnetClientFactory(None, 'ascii', None)
    telnet = TelnetClient(f)
    r = f.realm = Mock(spec=RootRealm)

    telnet.connectionMade()

    assert r.connectionMade.called
예제 #6
0
def test_HTMLLoggingModule_is_main_initialises_html_log():
    f = TelnetClientFactory(None, 'ascii', None)
    m = Mock()
    with nested(patched("mudpyl.library.html", "HTMLLogOutput", m),
                patched("mudpyl.library.html", "time")):
        mod = HTMLLoggingModule(f.realm)
        mod.logplace = sentinel.logplace
        mod.is_main(f.realm)
    assert m.call_args_list == [((f.realm, sentinel.logplace), {})]
예제 #7
0
 def test_highlights(self):
     m = Metaline("foo", RunLengthList([(0, 'foo')]), 
                  RunLengthList([(0, 'bar')]))
     root = RootRealm(TelnetClientFactory(None, None, None))
     realm = TriggerMatchingRealm(m, root, root, Mock())
     match = re.search('foobar', 'foobar')
     self.trig.func(match, realm)
     res = realm.alterer.apply(m)
     assert res.fores.items() == \
             [(0, HexFGCode(0x80, 0xFF, 0x80)),
              (6, 'foo')]
예제 #8
0
 def setUp(self):
     self.tc = TelnetClient(TelnetClientFactory(None, 'ascii', None))
     self.tc.transport = self.t = FakeTransport()
예제 #9
0
def test_TelnetClientFactory_sets_name():
    o = object()
    c = TelnetClientFactory(o, None, None)
    assert c.name is o
예제 #10
0
 def setUp(self):
     self.received = []
     self.tc = TelnetClient(TelnetClientFactory(None, 'ascii', None))
     self.tc.transport = FakeTransport()
     self.tc.lineReceived = self.lr
예제 #11
0
def test_TelnetclientFactory_sets_main_module_name():
    o = object()
    c = TelnetClientFactory(None, None, o)
    assert c.main_module_name is o
예제 #12
0
 def setUp(self):
     self.f = TelnetClientFactory(None, 'ascii', None)
     self.f.gui = Mock()
     self.tc = TelnetClient(self.f)
     self.tc.transport = FakeTransport()
예제 #13
0
def test_TelnetClientFactory_sets_encoding():
    o = object()
    c = TelnetClientFactory(None, o, None)
    assert c.encoding is o
예제 #14
0
 def setUp(self):
     self.fact = TelnetClientFactory(None, 'ascii', None)
     self.p = Mock()
     self.fact.realm.addProtocol(self.p)
     self.fact.realm.telnet = Mock(spec = TelnetClient)
     self.tc = TellColourer(self.fact.realm)