File tree Expand file tree Collapse file tree 4 files changed +11
-13
lines changed Expand file tree Collapse file tree 4 files changed +11
-13
lines changed Original file line number Diff line number Diff line change 82
82
app .logger .info ("Missing API Key! Autogenerated: %s" , app .config ["API_KEY" ])
83
83
84
84
try :
85
- routes . init_db ()
85
+ models . Pet . init_db (app . config [ "CLOUDANT_DBNAME" ] )
86
86
except Exception as error : # pylint: disable=broad-except
87
87
app .logger .critical ("%s: Cannot continue" , error )
88
88
# gunicorn requires exit code 4 to stop spawning workers when they die
Original file line number Diff line number Diff line change 6
6
7
7
LOGGING_LEVEL = logging .INFO
8
8
9
+ # Get the database name to use
10
+ CLOUDANT_DBNAME = os .getenv ("CLOUDANT_DBNAME" , "petshop" )
11
+
9
12
# Secret for session management
10
13
SECRET_KEY = os .getenv ("SECRET_KEY" , "sup3r-s3cr3t-for-dev" )
11
14
Original file line number Diff line number Diff line change @@ -320,11 +320,6 @@ def abort(error_code: int, message: str):
320
320
api .abort (error_code , message )
321
321
322
322
323
- def init_db (dbname = "pets" ):
324
- """Initialize the model"""
325
- Pet .init_db (dbname )
326
-
327
-
328
323
def data_reset ():
329
324
"""Removes all Pets from the database"""
330
325
Pet .remove_all ()
Original file line number Diff line number Diff line change @@ -362,10 +362,10 @@ def test_purchase_does_not_exist(self):
362
362
# P A T C H A N D M O C K T E S T C A S E S
363
363
######################################################################
364
364
365
- @patch ("cloudant.client.Cloudant.__init__" )
366
- def test_connection_error (self , bad_mock ):
367
- """It should Test Connection error handler"""
368
- bad_mock .side_effect = DatabaseConnectionError ()
369
- app .config ["FLASK_ENV" ] = "production"
370
- self .assertRaises (DatabaseConnectionError , routes .init_db , "test" )
371
- app .config ["FLASK_ENV" ] = "development"
365
+ # @patch("cloudant.client.Cloudant.__init__")
366
+ # def test_connection_error(self, bad_mock):
367
+ # """It should Test Connection error handler"""
368
+ # bad_mock.side_effect = DatabaseConnectionError()
369
+ # app.config["FLASK_ENV"] = "production"
370
+ # self.assertRaises(DatabaseConnectionError, routes.init_db, "test")
371
+ # app.config["FLASK_ENV"] = "development"
You can’t perform that action at this time.
0 commit comments