Cors + Tests
This commit is contained in:
parent
5f590b2cb0
commit
a398b49a98
4 changed files with 5 additions and 9 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
|
|
||||||
db = SQLAlchemy()
|
db = SQLAlchemy()
|
||||||
|
|
||||||
|
|
@ -23,13 +22,9 @@ def create_app(flask_env='development'):
|
||||||
else:
|
else:
|
||||||
print('ENV Variables passed : ', app.config['SQLALCHEMY_BINDS'])
|
print('ENV Variables passed : ', app.config['SQLALCHEMY_BINDS'])
|
||||||
|
|
||||||
print('init_app')
|
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
#print('import routes')
|
|
||||||
from . import routes
|
from . import routes
|
||||||
app.register_blueprint(routes.bp)
|
app.register_blueprint(routes.bp)
|
||||||
#print('db.create_all')
|
|
||||||
db.create_all()
|
db.create_all()
|
||||||
#print('db created')
|
|
||||||
return app
|
return app
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ def login():
|
||||||
elif res['status'] == 1:
|
elif res['status'] == 1:
|
||||||
user = None
|
user = None
|
||||||
token = create_auth_token(user)
|
token = create_auth_token(user)
|
||||||
return send_error(404, res['message'], token)
|
return send_error(400, res['message'], token)
|
||||||
else:
|
else:
|
||||||
return send_error(400, 'Empty email and/or password fields.')
|
return send_error(400, 'Empty email and/or password fields.')
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,5 @@ pipreqs==0.4.10
|
||||||
PyJWT==2.3.0
|
PyJWT==2.3.0
|
||||||
pytest==6.2.5
|
pytest==6.2.5
|
||||||
SQLAlchemy==1.4.27
|
SQLAlchemy==1.4.27
|
||||||
psycopg2==2.9.2
|
psycopg2==2.9.2
|
||||||
|
Flask-Cors==3.0.10
|
||||||
|
|
@ -66,7 +66,7 @@ class FlaskTestCase(BaseTestCase):
|
||||||
"password": "nimp"
|
"password": "nimp"
|
||||||
}
|
}
|
||||||
response = self.client.post('/api/login', json=data0)
|
response = self.client.post('/api/login', json=data0)
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 400)
|
||||||
|
|
||||||
def test_login_wrongFields_message(self):
|
def test_login_wrongFields_message(self):
|
||||||
data0 = {
|
data0 = {
|
||||||
|
|
@ -492,7 +492,7 @@ class FlaskTestCase(BaseTestCase):
|
||||||
def test_adminDelete_noFields_statusCode(self):
|
def test_adminDelete_noFields_statusCode(self):
|
||||||
response = self.login('daisy@gmail.com', 'daisyPass')
|
response = self.login('daisy@gmail.com', 'daisyPass')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
response = self.client.delete('/api/admin/delete/user')
|
response = self.client.delete('/api/admin/delete/user/')
|
||||||
self.assertEqual(response.status_code, 404)
|
self.assertEqual(response.status_code, 404)
|
||||||
|
|
||||||
def test_adminDelete_no_fields(self):
|
def test_adminDelete_no_fields(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue