mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
List and individual job pages now fetch data from api.
Few bug fixes around job uuid.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from flask import url_for
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
def test_should_return_list_of_all_jobs(app_,
|
||||
@@ -6,14 +7,18 @@ def test_should_return_list_of_all_jobs(app_,
|
||||
api_user_active,
|
||||
mock_get_user,
|
||||
mock_get_user_by_email,
|
||||
mock_login):
|
||||
mock_login,
|
||||
mock_get_jobs):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for('main.view_jobs', service_id=101))
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'You haven’t sent any notifications yet' in response.get_data(as_text=True)
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
assert page.h1.string == 'Notifications activity'
|
||||
jobs = page.tbody.find_all('tr')
|
||||
assert len(jobs) == 5
|
||||
|
||||
|
||||
def test_should_show_page_for_one_job(app_,
|
||||
@@ -21,35 +26,17 @@ def test_should_show_page_for_one_job(app_,
|
||||
api_user_active,
|
||||
mock_login,
|
||||
mock_get_user,
|
||||
mock_get_user_by_email):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
# TODO filename will be part of job metadata not in session
|
||||
with client.session_transaction() as s:
|
||||
s[456] = 'dispatch_20151114.csv'
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for('main.view_job', service_id=123, job_id=456))
|
||||
mock_get_user_by_email,
|
||||
job_data,
|
||||
mock_get_job):
|
||||
service_id = job_data['service']
|
||||
job_id = job_data['id']
|
||||
file_name = job_data['original_file_name']
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'dispatch_20151114.csv' in response.get_data(as_text=True)
|
||||
assert 'Test message 1' in response.get_data(as_text=True)
|
||||
|
||||
|
||||
def test_should_show_page_for_one_notification(app_,
|
||||
service_one,
|
||||
api_user_active,
|
||||
mock_get_user,
|
||||
mock_get_user_by_email,
|
||||
mock_login):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(api_user_active)
|
||||
response = client.get(url_for(
|
||||
'main.view_notification',
|
||||
service_id=101,
|
||||
job_id=123,
|
||||
notification_id=3))
|
||||
response = client.get(url_for('main.view_job', service_id=service_id, job_id=job_id))
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Text message' in response.get_data(as_text=True)
|
||||
assert '+44 7700 900 522' in response.get_data(as_text=True)
|
||||
assert file_name in response.get_data(as_text=True)
|
||||
|
||||
@@ -124,10 +124,12 @@ def test_create_job_should_call_api(app_,
|
||||
mock_get_user_by_email,
|
||||
mock_login,
|
||||
job_data,
|
||||
mock_create_job):
|
||||
mock_create_job,
|
||||
mock_get_job):
|
||||
|
||||
import uuid
|
||||
service_id = service_one['id']
|
||||
job_id = job_data['id']
|
||||
job_id = str(uuid.uuid4())
|
||||
file_name = job_data['file_name']
|
||||
|
||||
# TODO - template id should come from form but is not wired in yet.
|
||||
@@ -141,5 +143,5 @@ def test_create_job_should_call_api(app_,
|
||||
response = client.post(url, data=job_data, follow_redirects=True)
|
||||
|
||||
assert response.status_code == 200
|
||||
mock_create_job.assert_called_with(service_id, template_id, file_name)
|
||||
mock_create_job.assert_called_with(job_id, service_id, template_id, file_name)
|
||||
assert job_data['bucket_name'] == "service-{}-{}-notify".format(service_id, job_id)
|
||||
|
||||
Reference in New Issue
Block a user