mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-16 19:30:13 -04:00
update tests to reflect new code
also change jobs.py to filter out test jobs (since we dont need to see em) and to use the new statuses filter rather than filtering on front end
This commit is contained in:
@@ -182,7 +182,10 @@ def test_should_show_upcoming_jobs_on_dashboard(
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for('main.service_dashboard', service_id=SERVICE_ONE_ID))
|
||||
|
||||
mock_get_jobs.assert_called_once_with(SERVICE_ONE_ID, limit_days=7)
|
||||
first_call = mock_get_jobs.call_args_list[0]
|
||||
assert first_call[0] == (SERVICE_ONE_ID,)
|
||||
assert first_call[1]['statuses'] == ['scheduled']
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
@@ -218,7 +221,10 @@ def test_should_show_recent_jobs_on_dashboard(
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for('main.service_dashboard', service_id=SERVICE_ONE_ID))
|
||||
|
||||
mock_get_jobs.assert_called_once_with(SERVICE_ONE_ID, limit_days=7)
|
||||
second_call = mock_get_jobs.call_args_list[1]
|
||||
assert second_call[0] == (SERVICE_ONE_ID,)
|
||||
assert 'scheduled' not in second_call[1]['statuses']
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
|
||||
@@ -12,11 +12,13 @@ from tests import notification_json
|
||||
from freezegun import freeze_time
|
||||
|
||||
|
||||
def test_should_return_list_of_all_jobs(app_,
|
||||
service_one,
|
||||
active_user_with_permissions,
|
||||
mock_get_jobs,
|
||||
mocker):
|
||||
def test_should_return_list_of_all_real_jobs(
|
||||
app_,
|
||||
service_one,
|
||||
active_user_with_permissions,
|
||||
mock_get_jobs,
|
||||
mocker
|
||||
):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(active_user_with_permissions, mocker, service_one)
|
||||
@@ -25,8 +27,9 @@ def test_should_return_list_of_all_jobs(app_,
|
||||
assert response.status_code == 200
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
assert page.h1.string == 'Uploaded files'
|
||||
jobs = page.tbody.find_all('tr')
|
||||
assert len(jobs) == 5
|
||||
jobs = [x.text for x in page.tbody.find_all('a', {'class':'file-list-filename'})]
|
||||
assert len(jobs) == 4
|
||||
assert 'Test message' not in jobs
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import uuid
|
||||
from unittest.mock import ANY
|
||||
|
||||
from app.notify_client.job_api_client import JobApiClient
|
||||
|
||||
|
||||
@@ -51,8 +54,6 @@ def test_client_schedules_job(mocker, fake_uuid):
|
||||
|
||||
|
||||
def test_client_gets_job_by_service_and_job(mocker):
|
||||
mocker.patch('app.notify_client.current_user', id='1')
|
||||
|
||||
service_id = 'service_id'
|
||||
job_id = 'job_id'
|
||||
|
||||
@@ -66,9 +67,15 @@ def test_client_gets_job_by_service_and_job(mocker):
|
||||
mock_get.assert_called_once_with(url=expected_url, params={})
|
||||
|
||||
|
||||
def test_client_parses_job_stats(mocker):
|
||||
mocker.patch('app.notify_client.current_user', id='1')
|
||||
def test_client_gets_jobs_with_status_filter(mocker):
|
||||
mock_get = mocker.patch('app.notify_client.job_api_client.JobApiClient.get')
|
||||
|
||||
JobApiClient().get_jobs(uuid.uuid4(), statuses=['foo', 'bar'])
|
||||
|
||||
mock_get.assert_called_once_with(url=ANY, params={'statuses': 'foo,bar'})
|
||||
|
||||
|
||||
def test_client_parses_job_stats(mocker):
|
||||
service_id = 'service_id'
|
||||
job_id = 'job_id'
|
||||
expected_data = {'data': {
|
||||
@@ -114,8 +121,6 @@ def test_client_parses_job_stats(mocker):
|
||||
|
||||
|
||||
def test_client_parses_empty_job_stats(mocker):
|
||||
mocker.patch('app.notify_client.current_user', id='1')
|
||||
|
||||
service_id = 'service_id'
|
||||
job_id = 'job_id'
|
||||
expected_data = {'data': {
|
||||
@@ -152,8 +157,6 @@ def test_client_parses_empty_job_stats(mocker):
|
||||
|
||||
|
||||
def test_client_parses_job_stats_for_service(mocker):
|
||||
mocker.patch('app.notify_client.current_user', id='1')
|
||||
|
||||
service_id = 'service_id'
|
||||
job_1_id = 'job_id_1'
|
||||
job_2_id = 'job_id_2'
|
||||
@@ -232,8 +235,6 @@ def test_client_parses_job_stats_for_service(mocker):
|
||||
|
||||
|
||||
def test_client_parses_empty_job_stats_for_service(mocker):
|
||||
mocker.patch('app.notify_client.current_user', id='1')
|
||||
|
||||
service_id = 'service_id'
|
||||
job_1_id = 'job_id_1'
|
||||
job_2_id = 'job_id_2'
|
||||
@@ -294,7 +295,6 @@ def test_client_parses_empty_job_stats_for_service(mocker):
|
||||
|
||||
|
||||
def test_cancel_job(mocker):
|
||||
|
||||
mock_post = mocker.patch('app.notify_client.job_api_client.JobApiClient.post')
|
||||
|
||||
JobApiClient().cancel_job('service_id', 'job_id')
|
||||
|
||||
Reference in New Issue
Block a user