Example #1
0
 def _test_page(self, url, pause=False):
     router = get_routes()
     with run_test_server(self.loop, router=router, port=9999) as httpd:
         url = httpd.url(url)
         print(url)
         meth = 'get'
         r = self.loop.run_until_complete(
             self._run_phantom(url))
         if pause:
             pass
         spec = []
         startspec = False
         sj_debug() ###############################################################
         print ("\n".join(r))
         for line in r:
             if line.startswith('ENDSPEC'):
                 break
             if startspec:
                 spec.append(line)
             if line.startswith('STARTSPEC'):
                 startspec = True
         spec = json.loads("".join(spec))
         for sp in spec:
             print(sp['description'])
             print("\t"+sp['status'])
Example #2
0
 def test_main_page_ghost(self):
     from ghost import Ghost
     import logging
     logging.basicConfig(level=logging.DEBUG)
     router = get_static_routes()
     router.add_handler('/', get_routes())
     with run_test_server(self.loop, router=router, port=9999) as httpd:
         url = httpd.url("/")
         print(url)
         meth = 'get'
         ghost = Ghost()
         page, extra_resources = ghost.open(url)
         assert page.http_status == 200 
Example #3
0
    def test_static_file(self):
        router = Router()
        router.add_handler("/static/(.*)$", self.handler, 
                           dict(staticroot="static", baseurl="/static/"))
        with run_test_server(self.loop, router=router) as httpd:
            url = httpd.url('static', 'test.js')
            meth = 'get'
            r = self.loop.run_until_complete(
                client.request(meth, url))
            content1 = self.loop.run_until_complete(r.read())
            content = content1.decode()

            self.assertEqual(r.status, 200)
            self.cookies = r.cookies
            r.close()