Exemplo n.º 1
0
class test_handlers:
    def setUp(self):
        self.jid = "[email protected]/HermesClient"
        self.password = "******"
        self.endpoint = ("zuwiki.net", 5222)
        self.dispatcher = Dispatcher(self.jid, self.password, self.endpoint)

    def test_should_setup_handlers_for_pages(self):
        self.dispatcher.load('print("test")\n\n[--endscript--]\n\nTestcontent', "*****@*****.**")
        assert len(self.dispatcher.event_handlers) == 1
Exemplo n.º 2
0
class test_loading_pages:
    def setUp(self):
        self.dispatcher = Dispatcher()
        self.text = "This is only text. No trickery here."
        self.script = 'page.content = page.content + " Although now there is!"'
        self.jid = "[email protected]/www"

    def test_should_load_simple_text_page(self):
        self.dispatcher.load(self.text, self.jid)
        assert self.dispatcher.pages[self.jid].content == Page(self.text).content

    def test_should_load_page_with_script(self):
        self.dispatcher.load("%s\n[--endscript--]\n%s" % (self.script, self.text), self.jid)
        assert self.dispatcher.pages[self.jid].content == self.text
        assert self.dispatcher.pages[self.jid].script.body == self.script