Пример #1
0
 def test_set_password(self, getpass_mock):
     getpass_mock.return_value = PASSWORD
     server.update_password(PASSWORD_FILE, PASSWORD, server.get_secret(SECRET_FILE))
     APP.set_password()
     self.assertEqual(APP.password_hash, server.calc_hash(
         PASSWORD, APP.settings.get('cookie_secret')))
     os.remove(PASSWORD_FILE)
     APP.set_password()
     self.assertTrue(getpass_mock.called)
     self.assertEqual(APP.password_hash, server.calc_hash(
         PASSWORD, APP.settings.get('cookie_secret')))
Пример #2
0
import os
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):
Пример #3
0
 def test_update_password(self):
     password_hash = server.update_password(PASSWORD_FILE, PASSWORD, server.get_secret(SECRET_FILE))
     self.assertIsInstance(password_hash, basestring)
     self.assertEqual(
         password_hash, server.calc_hash(PASSWORD, server.get_secret(SECRET_FILE))
     )