config fix
* FLASK_ENV (new in Flask 1.0) * eslint config (corrects directories and rules) * minor fixes Note: still having problems w/ database used by pytest
This commit is contained in:
@ -153,17 +153,12 @@ def delete_sport(auth_user_id, sport_id):
|
||||
try:
|
||||
sport = Sport.query.filter_by(id=sport_id).first()
|
||||
if sport:
|
||||
db.session.query(Sport).filter_by(id=sport_id).delete()
|
||||
db.session.delete(sport)
|
||||
db.session.commit()
|
||||
response_object = {
|
||||
'status': 'no content',
|
||||
'data': {
|
||||
'sports': sports_list
|
||||
}
|
||||
'status': 'no content'
|
||||
}
|
||||
code = 204
|
||||
print('OK')
|
||||
print(response_object)
|
||||
else:
|
||||
response_object = {
|
||||
'status': 'not found',
|
||||
|
@ -20,8 +20,7 @@ class BaseConfig:
|
||||
class DevelopmentConfig(BaseConfig):
|
||||
"""Development configuration"""
|
||||
DEBUG = True
|
||||
SQLALCHEMY_DATABASE_URI = \
|
||||
os.environ.get('DATABASE_URL')
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
|
||||
SECRET_KEY = 'development key'
|
||||
USERNAME = 'admin'
|
||||
PASSWORD = 'default'
|
||||
@ -32,8 +31,7 @@ class TestingConfig(BaseConfig):
|
||||
"""Testing configuration"""
|
||||
DEBUG = True
|
||||
TESTING = True
|
||||
SQLALCHEMY_DATABASE_URI = \
|
||||
os.environ.get('DATABASE_TEST_URL')
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_TEST_URL')
|
||||
SECRET_KEY = 'test key'
|
||||
USERNAME = 'admin'
|
||||
PASSWORD = 'default'
|
||||
|
@ -1,11 +1,15 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from mpwo_api import create_app, db
|
||||
|
||||
os.environ["FLASK_ENV"] = 'testing'
|
||||
os.environ["APP_SETTINGS"] = 'mpwo_api.config.TestingConfig'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app():
|
||||
app = create_app()
|
||||
app.config.from_object('mpwo_api.config.TestingConfig')
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
yield app
|
||||
|
Reference in New Issue
Block a user