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:
parent
e423c355b5
commit
fd8b51f416
@ -376,7 +376,13 @@
|
|||||||
"import/no-named-as-default": "warn",
|
"import/no-named-as-default": "warn",
|
||||||
"import/no-named-as-default-member": "warn",
|
"import/no-named-as-default-member": "warn",
|
||||||
"import/no-deprecated": "warn",
|
"import/no-deprecated": "warn",
|
||||||
"import/no-extraneous-dependencies": "warn",
|
"import/no-extraneous-dependencies": [
|
||||||
|
"warn",
|
||||||
|
{
|
||||||
|
"devDependencies": true,
|
||||||
|
"packageDir": "."
|
||||||
|
}
|
||||||
|
],
|
||||||
"import/no-mutable-exports": "warn",
|
"import/no-mutable-exports": "warn",
|
||||||
"import/unambiguous": "off",
|
"import/unambiguous": "off",
|
||||||
"import/no-commonjs": "off",
|
"import/no-commonjs": "off",
|
||||||
|
@ -5,7 +5,7 @@ CLIENT_PORT = 3000
|
|||||||
export REACT_APP_API_URL = http://$(HOST):$(API_PORT)
|
export REACT_APP_API_URL = http://$(HOST):$(API_PORT)
|
||||||
export FLASK_APP = $(PWD)/mpwo_api/server.py
|
export FLASK_APP = $(PWD)/mpwo_api/server.py
|
||||||
export APP_SETTINGS=mpwo_api.config.DevelopmentConfig
|
export APP_SETTINGS=mpwo_api.config.DevelopmentConfig
|
||||||
export FLASK_DEBUG = 1
|
export FLASK_ENV=development
|
||||||
export TEST_URL = http://$(HOST):$(CLIENT_PORT)
|
export TEST_URL = http://$(HOST):$(CLIENT_PORT)
|
||||||
export REQUIREMENTS = $(PWD)/mpwo_api/requirements.txt
|
export REQUIREMENTS = $(PWD)/mpwo_api/requirements.txt
|
||||||
export DATABASE_URL = postgres://mpwo:mpwo@$(HOST):5432/mpwo
|
export DATABASE_URL = postgres://mpwo:mpwo@$(HOST):5432/mpwo
|
||||||
|
@ -153,17 +153,12 @@ def delete_sport(auth_user_id, sport_id):
|
|||||||
try:
|
try:
|
||||||
sport = Sport.query.filter_by(id=sport_id).first()
|
sport = Sport.query.filter_by(id=sport_id).first()
|
||||||
if sport:
|
if sport:
|
||||||
db.session.query(Sport).filter_by(id=sport_id).delete()
|
db.session.delete(sport)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
response_object = {
|
response_object = {
|
||||||
'status': 'no content',
|
'status': 'no content'
|
||||||
'data': {
|
|
||||||
'sports': sports_list
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
code = 204
|
code = 204
|
||||||
print('OK')
|
|
||||||
print(response_object)
|
|
||||||
else:
|
else:
|
||||||
response_object = {
|
response_object = {
|
||||||
'status': 'not found',
|
'status': 'not found',
|
||||||
|
@ -20,8 +20,7 @@ class BaseConfig:
|
|||||||
class DevelopmentConfig(BaseConfig):
|
class DevelopmentConfig(BaseConfig):
|
||||||
"""Development configuration"""
|
"""Development configuration"""
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
SQLALCHEMY_DATABASE_URI = \
|
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
|
||||||
os.environ.get('DATABASE_URL')
|
|
||||||
SECRET_KEY = 'development key'
|
SECRET_KEY = 'development key'
|
||||||
USERNAME = 'admin'
|
USERNAME = 'admin'
|
||||||
PASSWORD = 'default'
|
PASSWORD = 'default'
|
||||||
@ -32,8 +31,7 @@ class TestingConfig(BaseConfig):
|
|||||||
"""Testing configuration"""
|
"""Testing configuration"""
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
TESTING = True
|
TESTING = True
|
||||||
SQLALCHEMY_DATABASE_URI = \
|
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_TEST_URL')
|
||||||
os.environ.get('DATABASE_TEST_URL')
|
|
||||||
SECRET_KEY = 'test key'
|
SECRET_KEY = 'test key'
|
||||||
USERNAME = 'admin'
|
USERNAME = 'admin'
|
||||||
PASSWORD = 'default'
|
PASSWORD = 'default'
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from mpwo_api import create_app, db
|
from mpwo_api import create_app, db
|
||||||
|
|
||||||
|
os.environ["FLASK_ENV"] = 'testing'
|
||||||
|
os.environ["APP_SETTINGS"] = 'mpwo_api.config.TestingConfig'
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def app():
|
def app():
|
||||||
app = create_app()
|
app = create_app()
|
||||||
app.config.from_object('mpwo_api.config.TestingConfig')
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
db.create_all()
|
db.create_all()
|
||||||
yield app
|
yield app
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Helmet } from 'react-helmet'
|
import { Helmet } from 'react-helmet'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { Link } from 'react-router-dom'
|
|
||||||
|
|
||||||
import { deleteData, updateData } from '../../../actions/index'
|
import { deleteData, updateData } from '../../../actions/index'
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ export default function AdminPage(props) {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{ results.map((result, idx) => (
|
{ results.map((result, idx) => (
|
||||||
|
// eslint-disable-next-line react/no-array-index-key
|
||||||
<tr key={idx}>
|
<tr key={idx}>
|
||||||
{ Object.keys(result).map(key => {
|
{ Object.keys(result).map(key => {
|
||||||
if (key === 'id') {
|
if (key === 'id') {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
"build": "cd mpwo_client && react-scripts build",
|
"build": "cd mpwo_client && react-scripts build",
|
||||||
"test": "cd mpwo_client && testcafe firefox e2e",
|
"test": "cd mpwo_client && testcafe firefox e2e",
|
||||||
"eject": "cd mpwo_client && react-scripts eject",
|
"eject": "cd mpwo_client && react-scripts eject",
|
||||||
"lint": "eslint --cache --ext .jsx --ext .js mpwo/src"
|
"lint": "eslint --cache --ext .jsx --ext .js mpwo_client/src"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-eslint": "^8.0.3",
|
"babel-eslint": "^8.0.3",
|
||||||
|
Loading…
Reference in New Issue
Block a user