<s> import unittest <EOL> from yapper import create_app , db <EOL> from yapper . blueprints . user . models import User , Role <EOL> class TestUserAddToDb ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . app = create_app ( '<STR_LIT:test>' ) <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_role_gets_id ( self ) : <EOL> role = Role ( name = '<STR_LIT>' ) <EOL> self . assertTrue ( role . id is None ) <EOL> db . session . add ( role ) <EOL> db . session . commit ( ) <EOL> self . assertFalse ( role . id is None ) <EOL> def test_user_gets_role_and_id ( self ) : <EOL> role = Role ( name = '<STR_LIT>' ) <EOL> self . assertTrue ( role . id is None ) <EOL> user = User ( email = '<STR_LIT>' , password = '<STR_LIT>' , role = role ) <EOL> self . assertTrue ( user . id is None ) <EOL> db . session . add ( user ) <EOL> db . session . commit ( ) <EOL> self . assertFalse ( role . id is None ) <EOL> self . assertFalse ( user . id is None ) <EOL> self . assertTrue ( user . role_id == role . id ) <EOL> self . assertTrue ( user . is_admin ( ) ) </s>
