Skip to content

Commit

Permalink
Change structure of files according to docs on flask extension develo…
Browse files Browse the repository at this point in the history
…pment.
  • Loading branch information
alekzvik committed Apr 7, 2012
1 parent 5289344 commit 91d50ee
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
File renamed without changes.
1 change: 0 additions & 1 deletion flaskext/__init__.py

This file was deleted.

3 changes: 1 addition & 2 deletions setup.py
Expand Up @@ -16,8 +16,7 @@
author_email='maxc@me.com',
description='Brcrypt hashing for Flask.',
long_description=__doc__,
packages=['flaskext'],
namespace_packages=['flaskext'],
py_modules=['flask_bcrypt'],
zip_safe=False,
platforms='any',
install_requires=[
Expand Down
17 changes: 8 additions & 9 deletions test_bcrypt.py
@@ -1,29 +1,29 @@
import unittest

import flask
from flaskext.bcrypt import Bcrypt, generate_password_hash, check_password_hash
from flask_bcrypt import Bcrypt, generate_password_hash, check_password_hash


class BasicTestCase(unittest.TestCase):

def setUp(self):
app = flask.Flask(__name__)
app.config['BCRYPT_LOG_ROUNDS'] = 6
self.bcrypt = Bcrypt(app)

def test_is_string(self):
pw_hash = self.bcrypt.generate_password_hash('secret')
self.assertTrue(isinstance(pw_hash, str))

def test_not_string(self):
pw_hash = self.bcrypt.generate_password_hash(42)
self.assertTrue(isinstance(pw_hash, str))

def test_custom_rounds(self):
password = 'secret'
pw_hash1 = self.bcrypt.generate_password_hash(password, 5)
self.assertNotEqual(password, pw_hash1)

def test_check_hash(self):
pw_hash = self.bcrypt.generate_password_hash('secret')
# check a correct password
Expand All @@ -36,17 +36,16 @@ def test_check_hash(self):
# check helpers
pw_hash = generate_password_hash('hunter2')
self.assertTrue(check_password_hash(pw_hash, 'hunter2'))

def test_check_hash_unicode_is_utf8(self):
password = u'\u2603'
pw_hash = self.bcrypt.generate_password_hash(password)
# check a correct password
self.assertTrue(self.bcrypt.check_password_hash(pw_hash, '\xe2\x98\x83'))

def test_rounds_set(self):
self.assertEquals(self.bcrypt._log_rounds, 6)


if __name__ == '__main__':
unittest.main()

0 comments on commit 91d50ee

Please sign in to comment.