我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用views.index()。
def router(app, sio) -> None: app.add_route(views.index, "/", methods=["GET"]) app.add_route(views.signup, "/signup", methods=["POST"]) app.add_route(views.signin, "/signin", methods=["POST"]) app.add_route(views.refresh, "/refresh", methods=["POST"]) app.add_route(views.signout, "/signout", methods=["POST"]) app.add_route(views.challenge, "/challenge/<token>", methods=["GET"]) app.static("/assets", pathjoin(".", "client", "assets")) sio.on("/join_queue", events.join_queue)
def test_about_from_index(self): """Test traveling from index to about page""" link = 'http://startupfairy.com/' httpretty.register_uri(httpretty.GET, link) response = requests.get(link) self.assertEqual(200, response.status_code) link = 'http://startupfairy.com/about' httpretty.register_uri(httpretty.GET, link, body='[{"title": "About | Startup Fairy"}]', content_type="application/json") response = requests.get(link) self.assertEqual(200, response.status_code) #self.assertEqual('', httpretty.last_request().body)
def test_index_1(self): """Test that index renders properly""" with app.test_request_context(): self.assertEqual(index() is not None, True)