コード例 #1
0
def test_get_named_config(test_type, environment, expected):
    """Assert that the named configurations can be loaded.

    Or that a KeyError is returned for missing config types.
    """
    if test_type == 'valid':
        assert isinstance(config.get_named_config(environment), expected)
    else:
        with pytest.raises(KeyError):
            config.get_named_config(environment)
コード例 #2
0
import psycopg2
import pycountry
import requests
from dotenv import load_dotenv, find_dotenv

from flask import Flask
from legal_api import db
from legal_api.config import get_named_config
from legal_api.models import Address, Business, Director, Filing
from sqlalchemy_continuum import versioning_manager
from sqlalchemy import text

load_dotenv(find_dotenv())

FLASK_APP = Flask(__name__)
FLASK_APP.config.from_object(get_named_config('production'))
db.init_app(FLASK_APP)

COLIN_API = os.getenv('COLIN_API', None)
if not COLIN_API:
    print('ERROR, no COLIN_API defined.')


def create_business(db, business_json):
    business = Business()
    business.identifier = business_json['business']['identifier']
    business.founding_date = business_json['business']['foundingDate']
    business.last_ledger_timestamp = business_json['business'][
        'lastLedgerTimestamp']
    business.legal_name = business_json['business']['legalName']
    business.founding_date = business_json['business']['foundingDate']