This commit is contained in:
Kenneth Kehl
2024-10-31 11:48:08 -07:00
parent bc7180185b
commit c33c7a5058
3 changed files with 18 additions and 15 deletions

View File

@@ -349,7 +349,7 @@
"filename": "tests/app/user/test_rest.py", "filename": "tests/app/user/test_rest.py",
"hashed_secret": "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33", "hashed_secret": "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33",
"is_verified": false, "is_verified": false,
"line_number": 822, "line_number": 826,
"is_secret": false "is_secret": false
} }
], ],
@@ -384,5 +384,5 @@
} }
] ]
}, },
"generated_at": "2024-10-31T18:32:23Z" "generated_at": "2024-10-31T18:48:03Z"
} }

View File

@@ -105,24 +105,23 @@ def check_job_status():
thirty_minutes_ago = utc_now() - timedelta(minutes=30) thirty_minutes_ago = utc_now() - timedelta(minutes=30)
thirty_five_minutes_ago = utc_now() - timedelta(minutes=35) thirty_five_minutes_ago = utc_now() - timedelta(minutes=35)
stmt = select(Job).where( incomplete_in_progress_jobs = select(Job).where(
Job.job_status == JobStatus.IN_PROGRESS, Job.job_status == JobStatus.IN_PROGRESS,
between(Job.processing_started, thirty_five_minutes_ago, thirty_minutes_ago), between(Job.processing_started, thirty_five_minutes_ago, thirty_minutes_ago),
) )
incomplete_in_progress_jobs = db.session.execute(stmt).scalars().all() # incomplete_in_progress_jobs = db.session.execute(stmt).scalars().all()
stmt = select(Job).where( incomplete_pending_jobs = select(Job).where(
Job.job_status == JobStatus.PENDING, Job.job_status == JobStatus.PENDING,
Job.scheduled_for.isnot(None), Job.scheduled_for.isnot(None),
between(Job.scheduled_for, thirty_five_minutes_ago, thirty_minutes_ago), between(Job.scheduled_for, thirty_five_minutes_ago, thirty_minutes_ago),
) )
incomplete_pending_jobs = db.session.execute(stmt).scalars().all() # incomplete_pending_jobs = db.session.execute(stmt).scalars().all()
jobs_not_complete_after_30_minutes = ( stmt = incomplete_in_progress_jobs.union(incomplete_pending_jobs).order_by(
incomplete_in_progress_jobs.union(incomplete_pending_jobs) Job.processing_started, Job.scheduled_for
.order_by(Job.processing_started, Job.scheduled_for)
.all()
) )
jobs_not_complete_after_30_minutes = db.session.execute(stmt).scalars().all()
# temporarily mark them as ERROR so that they don't get picked up by future check_job_status tasks # temporarily mark them as ERROR so that they don't get picked up by future check_job_status tasks
# if they haven't been re-processed in time. # if they haven't been re-processed in time.

View File

@@ -336,7 +336,8 @@ def test_post_user_attribute_with_updated_by_sends_notification_to_international
_data=update_dict, _data=update_dict,
) )
notification = Notification.query.first() stmt = select(Notification)
notification = db.session.execute(stmt).scalars().first()
assert ( assert (
notification.reply_to_text notification.reply_to_text
== current_app.config["NOTIFY_INTERNATIONAL_SMS_SENDER"] == current_app.config["NOTIFY_INTERNATIONAL_SMS_SENDER"]
@@ -526,7 +527,9 @@ def test_set_user_permissions_remove_old(admin_request, sample_user, sample_serv
) )
count = db.session.execute(query).scalar() or 0 count = db.session.execute(query).scalar() or 0
assert count == 1 assert count == 1
assert query.first().permission == PermissionType.MANAGE_SETTINGS query = select(Permission).where(Permission.user == sample_user)
first_permission = db.session.execute(query).scalars().first()
assert first_permission.permission == PermissionType.MANAGE_SETTINGS
def test_set_user_folder_permissions(admin_request, sample_user, sample_service): def test_set_user_folder_permissions(admin_request, sample_user, sample_service):
@@ -658,7 +661,8 @@ def test_send_already_registered_email(
_expected_status=204, _expected_status=204,
) )
notification = Notification.query.first() stmt = select(Notification)
notification = db.session.execute(stmt).scalars().first()
mocked.assert_called_once_with( mocked.assert_called_once_with(
([str(notification.id)]), queue="notify-internal-tasks" ([str(notification.id)]), queue="notify-internal-tasks"
) )
@@ -696,8 +700,8 @@ def test_send_user_confirm_new_email_returns_204(
_data=data, _data=data,
_expected_status=204, _expected_status=204,
) )
stmt = select(Notification)
notification = Notification.query.first() notification = db.session.execute(stmt).scalars().first()
mocked.assert_called_once_with( mocked.assert_called_once_with(
([str(notification.id)]), queue="notify-internal-tasks" ([str(notification.id)]), queue="notify-internal-tasks"
) )