mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 00:06:16 -04:00
fix more
This commit is contained in:
@@ -42,12 +42,17 @@ def test_move_notifications_does_nothing_if_notification_history_row_already_exi
|
||||
1,
|
||||
)
|
||||
|
||||
assert Notification.query.count() == 0
|
||||
assert _get_notification_count() == 0
|
||||
history = NotificationHistory.query.all()
|
||||
assert len(history) == 1
|
||||
assert history[0].status == NotificationStatus.DELIVERED
|
||||
|
||||
|
||||
def _get_notification_count():
|
||||
stmt = select(func.count()).select_from(Notification)
|
||||
return db.session.execute(stmt).scalar() or 0
|
||||
|
||||
|
||||
def test_move_notifications_only_moves_notifications_older_than_provided_timestamp(
|
||||
sample_template,
|
||||
):
|
||||
@@ -172,8 +177,10 @@ def test_move_notifications_just_deletes_test_key_notifications(sample_template)
|
||||
|
||||
assert result == 2
|
||||
|
||||
assert Notification.query.count() == 0
|
||||
assert NotificationHistory.query.count() == 2
|
||||
assert _get_notification_count() == 0
|
||||
stmt = select(func.count()).select_from(NotificationHistory)
|
||||
count = db.session.execute(stmt).scalar() or 0
|
||||
assert count == 2
|
||||
stmt = (
|
||||
select(func.count())
|
||||
.select_from(NotificationHistory)
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
from sqlalchemy import func, select
|
||||
|
||||
from app import db
|
||||
from app.dao.events_dao import dao_create_event
|
||||
from app.models import Event
|
||||
|
||||
|
||||
def test_create_event(notify_db_session):
|
||||
assert Event.query.count() == 0
|
||||
stmt = select(func.count()).select_from(Event)
|
||||
count = db.session.execute(stmt).scalar() or 0
|
||||
assert count == 0
|
||||
data = {
|
||||
"event_type": "sucessful_login",
|
||||
"data": {"something": "random", "in_fact": "could be anything"},
|
||||
@@ -12,6 +17,8 @@ def test_create_event(notify_db_session):
|
||||
event = Event(**data)
|
||||
dao_create_event(event)
|
||||
|
||||
assert Event.query.count() == 1
|
||||
stmt = select(func.count()).select_from(Event)
|
||||
count = db.session.execute(stmt).scalar() or 0
|
||||
assert count == 1
|
||||
event_from_db = Event.query.first()
|
||||
assert event == event_from_db
|
||||
|
||||
Reference in New Issue
Block a user