Пример #1
0
def setup_test_db():
    db_url = DSN.format(**test_config['postgres'])
    engine = create_engine(db_url)
    create_tables(engine)
Пример #2
0
def tables_and_data():
    create_tables()
    sample_data()
    yield
    drop_tables()
Пример #3
0
import psycopg2
from project.settings import config
from init_db import create_tables, create_engine, sample_data

DSN = "postgresql://{user}:{password}@{host}:{port}/{database}".format(**config['postgres'])
try:
    conn = psycopg2.connect(DSN)
    conn.close()
    try:
        engine = create_engine(DSN)
        create_tables(engine)
        sample_data(engine)
    except:
        pass
except psycopg2.OperationalError:
    raise
Пример #4
0
import jwt
import uuid

from flask import Flask, request, Response
from flask_cors import CORS
from datetime import datetime

from init_db import create_tables, put_items
from lambda_code import lambda_function

try:
    print('Initializing DynamoDB...')
    create_tables()
    put_items()
    print('DynamoDB Table created')
except Exception:
    pass

app = Flask(__name__)
CORS(app)

PREFIX = 'Bearer '

def get_authenticated_user(req):
    auth_header = req.headers.get('Authorization')
    if auth_header and auth_header.startswith(PREFIX):
        return jwt.decode(auth_header[len(PREFIX):], verify=False)

    return None

Пример #5
0
def sample_data_fixture():
    create_tables()
    sample = sample_data()
    yield sample
    drop_tables()