mirror of
https://github.com/GSA/notifications-api.git
synced 2026-04-04 09:29:28 -04:00
Fixed ordering of the notifications test
- was backwards
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from flask import current_app
|
||||
from app import db
|
||||
from app.models import Notification
|
||||
from sqlalchemy import asc
|
||||
from sqlalchemy import desc
|
||||
|
||||
|
||||
def dao_create_notification(notification):
|
||||
@@ -20,7 +20,7 @@ def get_notification_for_job(service_id, job_id, notification_id):
|
||||
|
||||
def get_notifications_for_job(service_id, job_id, page=1):
|
||||
query = Notification.query.filter_by(service_id=service_id, job_id=job_id)\
|
||||
.order_by(asc(Notification.created_at))\
|
||||
.order_by(desc(Notification.created_at))\
|
||||
.paginate(
|
||||
page=page,
|
||||
per_page=current_app.config['PAGE_SIZE']
|
||||
@@ -34,7 +34,7 @@ def get_notification(service_id, notification_id):
|
||||
|
||||
def get_notifications_for_service(service_id, page=1):
|
||||
print(service_id)
|
||||
query = Notification.query.filter_by(service_id=service_id).order_by(asc(Notification.created_at)).paginate(
|
||||
query = Notification.query.filter_by(service_id=service_id).order_by(desc(Notification.created_at)).paginate(
|
||||
page=page,
|
||||
per_page=current_app.config['PAGE_SIZE']
|
||||
)
|
||||
|
||||
@@ -261,7 +261,8 @@ def sample_notification(notify_db,
|
||||
notify_db_session,
|
||||
service=None,
|
||||
template=None,
|
||||
job=None):
|
||||
job=None,
|
||||
to_field=None):
|
||||
if service is None:
|
||||
service = sample_service(notify_db, notify_db_session)
|
||||
if template is None:
|
||||
@@ -270,7 +271,11 @@ def sample_notification(notify_db,
|
||||
job = sample_job(notify_db, notify_db_session, service=service, template=template)
|
||||
|
||||
notification_id = uuid.uuid4()
|
||||
to = '+44709123456'
|
||||
|
||||
if to_field:
|
||||
to = to_field
|
||||
else:
|
||||
to = '+44709123456'
|
||||
|
||||
data = {
|
||||
'id': notification_id,
|
||||
|
||||
@@ -126,10 +126,11 @@ def test_get_all_notifications_for_job_in_order(notify_api, notify_db, notify_db
|
||||
with notify_api.test_client() as client:
|
||||
main_job = sample_job(notify_db, notify_db_session, service=sample_service)
|
||||
another_job = sample_job(notify_db, notify_db_session, service=sample_service)
|
||||
from time import sleep
|
||||
|
||||
notification_1 = sample_notification(notify_db, notify_db_session, job=main_job)
|
||||
notification_2 = sample_notification(notify_db, notify_db_session, job=main_job)
|
||||
notification_3 = sample_notification(notify_db, notify_db_session, job=main_job)
|
||||
notification_1 = sample_notification(notify_db, notify_db_session, job=main_job, to_field="1")
|
||||
notification_2 = sample_notification(notify_db, notify_db_session, job=main_job, to_field="2")
|
||||
notification_3 = sample_notification(notify_db, notify_db_session, job=main_job, to_field="3")
|
||||
sample_notification(notify_db, notify_db_session, job=another_job)
|
||||
|
||||
auth_header = create_authorization_header(
|
||||
|
||||
Reference in New Issue
Block a user