Example #1
0
def test_app_client_sql_backed_development_env(main_json_sql_backend_fixture):
    flask_app = create_app(db_uri=TESTING_DB_URI, env=DEVELOPMENT)
    flask_app.config[APP_CONFIG_JSON] = MappingProxyType(main_json_sql_backend_fixture)
    flask_app.config[CONFIG_FILE_FOLDER] = TEST_APP_DEPLOY_DATA
    configure_backend(flask_app, models_path="test_app_deploy_data.models")
    # Flask provides a way to test your application by exposing the Werkzeug test Client
    # and handling the context locals for you.
    testing_client = flask_app
    # Establish an application context before running the tests.
    ctx = flask_app.app_context()
    # application context needs to be pushed to be able to handle GETs and POSTs
    ctx.push()
    # provide the testing client to the tests
    yield testing_client  # this is where the testing happens!
    # remove the context to clean up the test environment
    ctx.pop()
Example #2
0
def test_app_client_csv_backed(main_json_csv_backend_fixture):

    flask_app = create_app()
    flask_app.config[APP_CONFIG_JSON] = MappingProxyType(
        main_json_csv_backend_fixture)
    flask_app.config[CONFIG_FILE_FOLDER] = TEST_APP_DEPLOY_DATA
    configure_backend(flask_app)
    # Flask provides a way to test your application by exposing the Werkzeug test Client
    # and handling the context locals for you.
    testing_client = flask_app.test_client()
    # Establish an application context before running the tests.
    ctx = flask_app.app_context()
    # application context needs to be pushed to be able to handle GETs and POSTs
    ctx.push()
    # provide the testing client to the tests
    yield testing_client  # this is where the testing happens!
    # remove the context to clean up the test environment
    ctx.pop()
Example #3
0
 def setUp(self) -> None:
     os.environ["FLASK_ENV"] = "testing"
     self.app = create_app()
     self.client = self.app.test_client(use_cookies=True)
     self.base_url = '/sensors/moving-average-weekly?'
Example #4
0
import json
import os

from app_setup import create_app, configure_app
from utility.constants import APP_DEPLOY_DATA

# from utility.constants import TEST_APP_DEPLOY_DATA as APP_DEPLOY_DATA

if os.environ.get("CONFIG_FILE_PATH"):
    config_file_path = os.environ["CONFIG_FILE_PATH"]
else:
    config_file_path = os.path.join("app_deploy_data", "main_config.json")

if os.environ.get("APP_DEPLOY_DATA"):
    app_deploy_data = os.environ["APP_DEPLOY_DATA"]
else:
    app_deploy_data = APP_DEPLOY_DATA

config_file_path = os.path.join("app_deploy_data", "main_config.json")
# config_file_path = "test_app_deploy_data/main_config.json"

with open(config_file_path, "r") as config_file:
    config_dict = json.load(config_file)
app = create_app()
app = configure_app(app=app,
                    config_dict=config_dict,
                    config_file_folder=app_deploy_data)

if __name__ == "__main__":
    app.run()
data_dict = defaultdict(dict)

for k, v in raw_data:
    data_dict[k]['cases'] = v

for k, v in tested_people:
    data_dict[k]['tested_people'] = v

for k, v in tests:
    data_dict[k]['tests'] = v

for k, v in raw_data_dead:
    data_dict[k]['dead'] = v

print(data_dict)
app, db = create_app()

with app.app_context():
    for date, values in data_dict.items():
        data_obj = Data(date=datetime.datetime.strptime(date,
                                                        iso_format).date(),
                        **values)
        db.session.add(data_obj)

    db.session.add(
        Data(date=datetime.date(2020, 4, 1),
             cases=2460,
             tests=26609,
             dead=85,
             icu=57,
             critical=34,
Example #6
0
def app():
    # create the app instance
    os.environ["FLASK_ENV"] = "testing"
    app = create_app()
    return app