fix test create_app invocation

This commit is contained in:
Leo Hemsted
2017-11-22 17:54:59 +00:00
parent d30a8b83c1
commit 5466b7cd3c
2 changed files with 5 additions and 7 deletions

View File

@@ -1,12 +1,12 @@
from datetime import datetime from datetime import datetime
from app.commands import BackfillProcessingTime from app.commands import backfill_processing_time
def test_backfill_processing_time_works_for_correct_dates(mocker): def test_backfill_processing_time_works_for_correct_dates(mocker):
send_mock = mocker.patch('app.commands.send_processing_time_for_start_and_end') send_mock = mocker.patch('app.commands.send_processing_time_for_start_and_end')
BackfillProcessingTime().run('2017-08-01', '2017-08-03') backfill_processing_time.callback('2017-08-01', '2017-08-03')
assert send_mock.call_count == 3 assert send_mock.call_count == 3
send_mock.assert_any_call(datetime(2017, 7, 31, 23, 0), datetime(2017, 8, 1, 23, 0)) send_mock.assert_any_call(datetime(2017, 7, 31, 23, 0), datetime(2017, 8, 1, 23, 0))

View File

@@ -1,10 +1,9 @@
from contextlib import contextmanager from contextlib import contextmanager
import os import os
from flask import Flask
from alembic.command import upgrade from alembic.command import upgrade
from alembic.config import Config from alembic.config import Config
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
import boto3 import boto3
import pytest import pytest
import sqlalchemy import sqlalchemy
@@ -14,7 +13,8 @@ from app import create_app, db
@pytest.fixture(scope='session') @pytest.fixture(scope='session')
def notify_api(): def notify_api():
app = create_app() app = Flask('test')
create_app(app)
# deattach server-error error handlers - error_handler_spec looks like: # deattach server-error error handlers - error_handler_spec looks like:
# {'blueprint_name': { # {'blueprint_name': {
@@ -76,8 +76,6 @@ def notify_db(notify_api, worker_id):
current_app.config['SQLALCHEMY_DATABASE_URI'] += '_{}'.format(worker_id) current_app.config['SQLALCHEMY_DATABASE_URI'] += '_{}'.format(worker_id)
create_test_db(current_app.config['SQLALCHEMY_DATABASE_URI']) create_test_db(current_app.config['SQLALCHEMY_DATABASE_URI'])
Migrate(notify_api, db)
Manager(db, MigrateCommand)
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) BASE_DIR = os.path.dirname(os.path.dirname(__file__))
ALEMBIC_CONFIG = os.path.join(BASE_DIR, 'migrations') ALEMBIC_CONFIG = os.path.join(BASE_DIR, 'migrations')
config = Config(ALEMBIC_CONFIG + '/alembic.ini') config = Config(ALEMBIC_CONFIG + '/alembic.ini')