Merge pull request #150 from alphagov/send-text-flow-revised

Send text flow revised
This commit is contained in:
NIcholas Staples
2016-02-04 14:57:43 +00:00
31 changed files with 208 additions and 228 deletions

View File

@@ -7,7 +7,8 @@ def test_should_show_recent_jobs_on_dashboard(app_,
mock_get_service_templates,
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:

View File

@@ -27,6 +27,7 @@ def test_should_show_page_for_one_job(app_,
mock_login,
mock_get_user,
mock_get_user_by_email,
mock_get_service_template,
job_data,
mock_get_job):
service_id = job_data['service']

View File

@@ -18,7 +18,8 @@ def test_sign_out_user(app_,
mock_get_user,
mock_get_user_by_email,
mock_get_service_templates,
mock_login):
mock_login,
mock_get_jobs):
with app_.test_request_context():
email = 'valid@example.gov.uk'
password = 'val1dPassw0rd!'

View File

@@ -23,24 +23,6 @@ def test_choose_sms_template(app_,
assert 'template two content' in content
def test_choose_sms_template_redirects(app_,
api_user_active,
mock_get_user,
mock_get_service_templates,
mock_check_verify_code,
mock_get_service_template):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.post(
url_for('main.choose_sms_template', service_id=12345),
data={'template': '54321'}
)
assert response.status_code == 302
assert response.location == url_for('main.send_sms', service_id=12345, template_id=54321, _external=True)
def test_upload_empty_csvfile_returns_to_upload_page(app_,
api_user_active,
mock_get_user,
@@ -87,50 +69,13 @@ def test_upload_csvfile_with_invalid_phone_shows_check_page_with_errors(app_,
@moto.mock_s3
def test_upload_csvfile_with_valid_phone_shows_first3_and_last3_numbers(app_,
mocker,
api_user_active,
mock_get_user,
mock_get_user_by_email,
mock_login,
mock_get_service_template):
contents = 'phone\n+44 7700 900981\n+44 7700 900982\n+44 7700 900983\n+44 7700 900984\n+44 7700 900985\n+44 7700 900986\n+44 7700 900987\n+44 7700 900988\n+44 7700 900989' # noqa
file_data = (BytesIO(contents.encode('utf-8')), 'valid.csv')
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
upload_data = {'file': file_data}
response = client.post(url_for('main.send_sms', service_id=12345, template_id=54321),
data=upload_data,
follow_redirects=True)
content = response.get_data(as_text=True)
assert response.status_code == 200
assert 'Check and confirm' in content
assert 'First three message in file' in content
assert 'Last three messages in file' in content
assert '+44 7700 900981' in content
assert '+44 7700 900982' in content
assert '+44 7700 900983' in content
assert '+44 7700 900984' not in content
assert '+44 7700 900985' not in content
assert '+44 7700 900986' not in content
assert '+44 7700 900987' in content
assert '+44 7700 900988' in content
assert '+44 7700 900989' in content
@moto.mock_s3
def test_upload_csvfile_with_valid_phone_shows_all_if_6_or_less_numbers(app_,
mocker,
api_user_active,
mock_get_user,
mock_get_user_by_email,
mock_login,
mock_get_service_template):
def test_upload_csvfile_with_valid_phone_shows_all_numbers(app_,
mocker,
api_user_active,
mock_get_user,
mock_get_user_by_email,
mock_login,
mock_get_service_template):
contents = 'phone\n+44 7700 900981\n+44 7700 900982\n+44 7700 900983\n+44 7700 900984\n+44 7700 900985\n+44 7700 900986' # noqa
@@ -147,8 +92,6 @@ def test_upload_csvfile_with_valid_phone_shows_all_if_6_or_less_numbers(app_,
content = response.get_data(as_text=True)
assert response.status_code == 200
assert 'Check and confirm' in content
assert 'All messages in file' in content
assert '+44 7700 900981' in content
assert '+44 7700 900982' in content
assert '+44 7700 900983' in content

View File

@@ -9,7 +9,8 @@ def test_should_return_list_of_all_templates(app_,
mock_get_service_templates,
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)