私はスクリプトを使用して単体テストに慣れています。私は、ポストデータ内の引数でログインを検証しようとしたが、私は、ログインせずに他の機能にアクセスすることはできません@tornado.web.authenticated
のin.Becauseを記録し得る応答としてログインページを取得していないですし、それがページtornado.testingを使って `@ authenticated`ハンドラをテストするには?
import tornado
from tornado.testing import AsyncTestCase
from tornado.web import Application, RequestHandler
import app
import urllib
class MyTestCase(AsyncTestCase):
@tornado.testing.gen_test
def test_http_fetch_login(self):
data = urllib.urlencode(dict(username='admin', password=''))
client = AsyncHTTPClient(self.io_loop)
response = yield client.fetch("http://localhost:8888/console/login/?", method="POST",body=data)
# Test contents of response
self.assertIn("Automaton web console", response.body)
@tornado.testing.gen_test
def test_http_fetch_config(self):
client = AsyncHTTPClient(self.io_loop)
response = yield client.fetch("http://localhost:8888/console/configuration/?")
self.assertIn("server-version",response.body)