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:
Leo Hemsted
2016-10-05 17:45:04 +01:00
parent 441a2717f2
commit aa458a15da
6 changed files with 53 additions and 32 deletions

View File

@@ -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')

View File

@@ -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(