mirror of
https://github.com/GSA/notifications-admin.git
synced 2025-12-10 15:13:40 -05:00
add in test and fix isort
This commit is contained in:
@@ -45,18 +45,20 @@ def all_jobs_activity(service_id):
|
||||
service_data_retention_days = 7
|
||||
page = get_page_from_request()
|
||||
|
||||
filter_type = request.args.get('filter')
|
||||
filter_type = request.args.get("filter")
|
||||
|
||||
limit_days = None
|
||||
if filter_type == '24hours':
|
||||
if filter_type == "24hours":
|
||||
limit_days = 1
|
||||
elif filter_type == '3days':
|
||||
elif filter_type == "3days":
|
||||
limit_days = 3
|
||||
elif filter_type == '7days':
|
||||
elif filter_type == "7days":
|
||||
limit_days = 7
|
||||
|
||||
if limit_days:
|
||||
jobs = job_api_client.get_page_of_jobs(service_id, page=page, limit_days=limit_days)
|
||||
jobs = job_api_client.get_page_of_jobs(
|
||||
service_id, page=page, limit_days=limit_days
|
||||
)
|
||||
else:
|
||||
jobs = job_api_client.get_page_of_jobs(service_id, page=page)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import multiprocessing
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
import gunicorn
|
||||
|
||||
# Let gunicorn figure out the right number of workers
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import json
|
||||
import logging
|
||||
import urllib.parse
|
||||
|
||||
from os import getenv
|
||||
|
||||
import requests
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import pytest
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from app.utils.pagination import get_page_from_request
|
||||
@@ -211,3 +212,35 @@ def test_all_activity_pagination(client_request, mocker):
|
||||
assert (
|
||||
pagination_texts == expected_pagination_texts
|
||||
), f"Expected pagination controls {expected_pagination_texts}, but got {pagination_texts}"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("filter_type,expected_limit_days", [
|
||||
("24hours", 1),
|
||||
("3days", 3),
|
||||
("7days", 7),
|
||||
(None, None),
|
||||
])
|
||||
def test_all_activity_filters(client_request, mocker, filter_type, expected_limit_days):
|
||||
current_page = get_page_from_request()
|
||||
mock_get_page_of_jobs = mocker.patch(
|
||||
"app.job_api_client.get_page_of_jobs", return_value=MOCK_JOBS
|
||||
)
|
||||
mocker.patch("app.job_api_client.get_immediate_jobs", return_value=[])
|
||||
|
||||
kwargs = {"filter": filter_type} if filter_type else {}
|
||||
response = client_request.get_response(
|
||||
"main.all_jobs_activity",
|
||||
service_id=SERVICE_ONE_ID,
|
||||
page=current_page,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "All activity" in response.text
|
||||
|
||||
if expected_limit_days:
|
||||
mock_get_page_of_jobs.assert_any_call(
|
||||
SERVICE_ONE_ID, page=current_page, limit_days=expected_limit_days
|
||||
)
|
||||
else:
|
||||
mock_get_page_of_jobs.assert_any_call(SERVICE_ONE_ID, page=current_page)
|
||||
|
||||
Reference in New Issue
Block a user