mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-25 12:01:38 -05:00
25 lines
720 B
Python
25 lines
720 B
Python
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):
|
|
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"},
|
|
}
|
|
|
|
event = Event(**data)
|
|
dao_create_event(event)
|
|
|
|
stmt = select(func.count()).select_from(Event)
|
|
count = db.session.execute(stmt).scalar() or 0
|
|
assert count == 1
|
|
event_from_db = db.session.execute(select(Event)).scalars().first()
|
|
assert event == event_from_db
|