def test_execute(self): empty = _(TEST_PATH + "/empty") ls = _("ls %s" % empty.path) self.assertEquals(ls.kind, "ls") self.assertEquals(ls.bunch, empty.path) res = ls.execute() self.assertEquals(res, empty.ls())
def dataReceived(self, body): path = '/' self.subscribe(path) res = _(body).execute() print "EXEC: %s => %s" % (body, res) if isinstance(res, Bunch): res = res.render(level=1) result = self.factory.mqm.send_message(self, path, res)
def dataReceived(self, body): path = "/" self.subscribe(path) res = _(body).execute() print "EXEC: %s => %s" % (body, res) if isinstance(res, Bunch): res = res.render(level=1) result = self.factory.mqm.send_message(self, path, res)
def test_subscribe(self): gotcha = [None, None] def handler(who, event): gotcha[0] = who gotcha[1] = event origin = _(TEST_PATH + "/origin") origin.subscribe(handler) origin.notify("Event") self.assertEquals(gotcha[0], origin) self.assertEquals(gotcha[1], "Event") origin.unsubscribe(handler) origin.notify("Nope") self.assertEquals(gotcha[1], "Event")
def test_render_cmd(self): cmd = _("render " + TEST_PATH) self.assertEquals(cmd.execute(), _(TEST_PATH).render())
def test_type(self): txt = _(TEST_PATH + "/txt", "test", "<html>\t</html>\r\n") self.assertEquals(txt.mimetype(), "text/html") self.assertFalse(txt.is_binary()) bin = _(TEST_PATH + "/bin", "test", "BIN\01\02\03\04") self.assertTrue(bin.is_binary())
def test_ls(self): empty = _(TEST_PATH + "/empty", "test", "Content") self.assertEquals(empty.ls(), empty.name() + ": Content") _(ROOT_SYS + "templates/menu.template") listing = _(ROOT_SYS + "templates").ls(level=2) self.assertTrue("menu.template" in listing)