def test_urlmap(self): def F(r): pass m = framework.URLMap(r'^/selftest/(?P<patt1>\S+)/(?P<patt2>\d+)/$', F) path = m.get_url(patt1="part1", patt2="22") print m print path self.assertEqual(path, "/selftest/part1/22/") self.assertTrue(m.match(path))
def GetMockEnviron(handler): environ = {} environ['REQUEST_METHOD'] = "POST" environ['PATH_INFO'] = "/proxy/_JsonTest" m = framework.URLMap(r'^/proxy/(?P<methodname>\w+)/$', handler) environ["framework.get_url"] = m.get_url q = 'data=%5B%22_JsonTest%22%2C+1%5D' # as PythonProxy would send a call from proxy._JsonTest(1) inp = StringIO(q) environ["CONTENT_TYPE"] = "application/x-www-form-urlencoded" environ["CONTENT_LENGTH"] = len(q) environ["wsgi.input"] = inp environ["wsgi.errors"] = sys.stderr return environ