# -*- coding: utf-8 -*- """Testing main page of application""" import os from tornado.options import options from tornado.testing import AsyncHTTPTestCase from todotxt_web import server APP = server.make_app() options.parse_config_file(os.path.join('test', 'config.py')) class TestHandlerBase(AsyncHTTPTestCase): """TestCase with initialized app""" def get_app(self): return APP # this is the global app that we created above. class TestTodoTxtWebMainPage(TestHandlerBase): def setUp(self): """Fetch main page to self.page""" super(TestTodoTxtWebMainPage, self).setUp() response = self.fetch('/') self.assertEqual(response.code, 200) self.page = response.buffer.read() def test_main_page(self):
import urllib from tornado.options import options from tornado.testing import AsyncHTTPTestCase from tornado.escape import json_encode, json_decode from todotxt_web import server from todotxt_web import todo_txt SECRET_FILE = 'test/secret' PASSWORD_FILE = 'test/password' PASSWORD = "******" server.update_password(PASSWORD_FILE, PASSWORD, server.get_secret(SECRET_FILE)) APP = server.make_app(secret_file=SECRET_FILE, password_file=PASSWORD_FILE) options.parse_config_file(os.path.join('test', 'config.py')) class TestHandlerBase(AsyncHTTPTestCase): """TestCase with initialized app""" def get_app(self): return APP # this is the global app that we created above. class TestTodoHandler(TestHandlerBase): def setUp(self): super(TestTodoHandler, self).setUp() self.todo = todo_txt.TodoTxt(options.todo_file)
# -*- coding: utf-8 -*- """Testing main page of application""" import os from tornado.options import options from tornado.testing import AsyncHTTPTestCase from todotxt_web import server APP = server.make_app() options.parse_config_file(os.path.join('test', 'config.py')) class TestHandlerBase(AsyncHTTPTestCase): """TestCase with initialized app""" def get_app(self): return APP # this is the global app that we created above. class TestTodoTxtWebMainPage(TestHandlerBase): def setUp(self): """Fetch main page to self.page""" super(TestTodoTxtWebMainPage, self).setUp() response = self.fetch('/') self.assertEqual(response.code, 200) self.page = response.buffer.read() def test_main_page(self): """Test fetching main page""" self.assertIn('todo.txt', self.page)