mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 08:51:30 -05:00
Merge branch 'master' into notification-created-status
This commit is contained in:
@@ -689,7 +689,7 @@ def test_update_notification(sample_notification, sample_template):
|
|||||||
def test_should_delete_notifications_after_seven_days(notify_db, notify_db_session):
|
def test_should_delete_notifications_after_seven_days(notify_db, notify_db_session):
|
||||||
assert len(Notification.query.all()) == 0
|
assert len(Notification.query.all()) == 0
|
||||||
|
|
||||||
# create one notification a day between 1st and 9th from 11:00 to 19:00
|
# create one notification a day between 1st and 10th from 11:00 to 19:00
|
||||||
for i in range(1, 11):
|
for i in range(1, 11):
|
||||||
past_date = '2016-01-{0:02d} {0:02d}:00:00.000000'.format(i, i)
|
past_date = '2016-01-{0:02d} {0:02d}:00:00.000000'.format(i, i)
|
||||||
with freeze_time(past_date):
|
with freeze_time(past_date):
|
||||||
@@ -702,7 +702,8 @@ def test_should_delete_notifications_after_seven_days(notify_db, notify_db_sessi
|
|||||||
delete_notifications_created_more_than_a_week_ago('failed')
|
delete_notifications_created_more_than_a_week_ago('failed')
|
||||||
remaining_notifications = Notification.query.all()
|
remaining_notifications = Notification.query.all()
|
||||||
assert len(remaining_notifications) == 8
|
assert len(remaining_notifications) == 8
|
||||||
assert remaining_notifications[0].created_at.date() == date(2016, 1, 3)
|
for notification in remaining_notifications:
|
||||||
|
assert notification.created_at.date() >= date(2016, 1, 3)
|
||||||
|
|
||||||
|
|
||||||
def test_should_not_delete_failed_notifications_before_seven_days(notify_db, notify_db_session):
|
def test_should_not_delete_failed_notifications_before_seven_days(notify_db, notify_db_session):
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ def notify_db(notify_api, request):
|
|||||||
|
|
||||||
def teardown():
|
def teardown():
|
||||||
db.session.remove()
|
db.session.remove()
|
||||||
db.drop_all()
|
|
||||||
db.get_engine(notify_api).dispose()
|
db.get_engine(notify_api).dispose()
|
||||||
|
|
||||||
request.addfinalizer(teardown)
|
request.addfinalizer(teardown)
|
||||||
@@ -47,15 +46,14 @@ def notify_db(notify_api, request):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def notify_db_session(request):
|
def notify_db_session(request, notify_db):
|
||||||
def teardown():
|
def teardown():
|
||||||
db.session.remove()
|
notify_db.session.remove()
|
||||||
for tbl in reversed(meta.sorted_tables):
|
for tbl in reversed(notify_db.metadata.sorted_tables):
|
||||||
if tbl.name not in ["provider_details"]:
|
if tbl.name not in ["provider_details"]:
|
||||||
db.engine.execute(tbl.delete())
|
notify_db.engine.execute(tbl.delete())
|
||||||
db.session.commit()
|
notify_db.session.commit()
|
||||||
|
|
||||||
meta = MetaData(bind=db.engine, reflect=True)
|
|
||||||
request.addfinalizer(teardown)
|
request.addfinalizer(teardown)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user