<s> import unittest <EOL> from app import create_app , db <EOL> from app . models import User <EOL> class UserModelTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . app = create_app ( '<STR_LIT>' ) <EOL> self . app_context = self . app . app_context ( ) <EOL> self . app_context . push ( ) <EOL> db . create_all ( ) <EOL> def tearDown ( self ) : <EOL> db . session . remove ( ) <EOL> db . drop_all ( ) <EOL> self . app_context . pop ( ) <EOL> def test_password_setter ( self ) : <EOL> u = User ( password = '<STR_LIT>' ) <EOL> self . assertTrue ( u . password_hash is not None ) <EOL> def test_no_password_getter ( self ) : <EOL> u = User ( password = '<STR_LIT>' ) <EOL> with self . assertRaises ( AttributeError ) : <EOL> u . password <EOL> def test_password_verification ( self ) : <EOL> u = User ( password = '<STR_LIT>' ) <EOL> self . assertTrue ( u . verify_password ( '<STR_LIT>' ) ) <EOL> self . assertFalse ( u . verify_password ( '<STR_LIT>' ) ) <EOL> def test_password_salts_are_random ( self ) : <EOL> u = User ( password = '<STR_LIT>' ) <EOL> u2 = User ( password = '<STR_LIT>' ) <EOL> self . assertTrue ( u . password_hash != u2 . password_hash ) </s>
