File tree 2 files changed +13
-11
lines changed
2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 11
11
def create_app (test_config = None ):
12
12
# create and configure the app
13
13
app = Flask (__name__ )
14
- setup_db (app )
14
+
15
+ if test_config is None :
16
+ setup_db (app )
17
+ else :
18
+ database_path = test_config .get ('SQLALCHEMY_DATABASE_URI' )
19
+ setup_db (app , database_path = database_path )
15
20
16
21
"""
17
22
@TODO: Set up CORS. Allow '*' for origins. Delete the sample route after completing the TODOs
Original file line number Diff line number Diff line change @@ -12,18 +12,15 @@ class TriviaTestCase(unittest.TestCase):
12
12
13
13
def setUp (self ):
14
14
"""Define test variables and initialize app."""
15
- self .app = create_app ()
16
- self .client = self .app .test_client
17
15
self .database_name = "trivia_test"
18
16
self .database_path = "postgres://{}/{}" .format ('localhost:5432' , self .database_name )
19
- setup_db (self .app , self .database_path )
20
-
21
- # binds the app to the current context
22
- with self .app .app_context ():
23
- self .db = SQLAlchemy ()
24
- self .db .init_app (self .app )
25
- # create all tables
26
- self .db .create_all ()
17
+
18
+ self .app = create_app ({
19
+ "SQLALCHEMY_DATABASE_URI" : self .database_path
20
+ })
21
+
22
+ self .client = self .app .test_client
23
+
27
24
28
25
def tearDown (self ):
29
26
"""Executed after reach test"""
You can’t perform that action at this time.
0 commit comments