Fix PEP8 issues

This commit is contained in:
Imdad Ahad
2016-09-27 14:16:35 +01:00
parent d258e29edc
commit af2cbaa9c5
4 changed files with 44 additions and 41 deletions

View File

@@ -144,6 +144,7 @@ EMAIL_TYPE = 'email'
WHITELIST_RECIPIENT_TYPE = [MOBILE_TYPE, EMAIL_TYPE]
whitelist_recipient_types = db.Enum(*WHITELIST_RECIPIENT_TYPE, name='recipient_type')
class ServiceWhitelist(db.Model):
__tablename__ = 'service_whitelist'

View File

@@ -254,7 +254,8 @@ def send_notification(notification_type):
notification['to'],
itertools.chain(
itertools.chain.from_iterable([user.mobile_number, user.email_address] for user in service.users),
([member.recipient for member in service.whitelist]) if api_user.key_type == KEY_TYPE_NORMAL else iter([])
([member.recipient for member in service.whitelist])
if api_user.key_type == KEY_TYPE_NORMAL else iter([])
)
)
)):

View File

@@ -1004,12 +1004,11 @@ def test_should_not_persist_notification_or_send_sms_if_simulated_number(
@pytest.mark.parametrize('to_sms', ['07827992635'])
def test_should_not_send_sms_to_non_whitelist_recipient_in_trial_mode_with_live_key(
client,
notify_db,
notify_db_session,
to_sms,
mocker):
def test_should_not_send_sms_to_non_whitelist_recipient_in_trial_mode_with_live_key(client,
notify_db,
notify_db_session,
to_sms,
mocker):
apply_async = mocker.patch('app.celery.provider_tasks.send_sms_to_provider.apply_async')
service = create_sample_service(notify_db, notify_db_session, limit=2, restricted=True)
service_whitelist = create_sample_service_whitelist(notify_db, notify_db_session, service=service)
@@ -1044,13 +1043,13 @@ def test_should_not_send_sms_to_non_whitelist_recipient_in_trial_mode_with_live_
assert expected_response_message in json_resp['message']['to']
apply_async.assert_not_called()
@pytest.mark.parametrize('to_email', ['non_whitelist_recipient@mail.com'])
def test_should_not_send_email_to_non_whitelist_recipient_in_trial_mode_with_live_key(
client,
notify_db,
notify_db_session,
to_email,
mocker):
def test_should_not_send_email_to_non_whitelist_recipient_in_trial_mode_with_live_key(client,
notify_db,
notify_db_session,
to_email,
mocker):
apply_async = mocker.patch('app.celery.provider_tasks.send_email_to_provider.apply_async')
service = create_sample_service(notify_db, notify_db_session, limit=2, restricted=True)
service_whitelist = create_sample_service_whitelist(notify_db, notify_db_session, service=service)
@@ -1087,15 +1086,15 @@ def test_should_not_send_email_to_non_whitelist_recipient_in_trial_mode_with_liv
@pytest.mark.parametrize('to_sms', ['07827992635'])
def test_should_not_send_sms_to_whitelist_recipient_in_trial_mode_with_team_key(
client,
notify_db,
notify_db_session,
to_sms,
mocker):
def test_should_not_send_sms_to_whitelist_recipient_in_trial_mode_with_team_key(client,
notify_db,
notify_db_session,
to_sms,
mocker):
apply_async = mocker.patch('app.celery.provider_tasks.send_sms_to_provider.apply_async')
service = create_sample_service(notify_db, notify_db_session, limit=2, restricted=True)
service_whitelist = create_sample_service_whitelist(notify_db, notify_db_session, service=service, mobile_number=to_sms)
service_whitelist = create_sample_service_whitelist(notify_db, notify_db_session,
service=service, mobile_number=to_sms)
sms_template = create_sample_template(notify_db, notify_db_session, service=service)
assert service_whitelist.service_id == service.id
@@ -1124,15 +1123,15 @@ def test_should_not_send_sms_to_whitelist_recipient_in_trial_mode_with_team_key(
@pytest.mark.parametrize('to_email', ['non_whitelist_recipient@mail.com'])
def test_should_not_send_email_to_whitelist_recipient_in_trial_mode_with_team_key(
client,
notify_db,
notify_db_session,
to_email,
mocker):
def test_should_not_send_email_to_whitelist_recipient_in_trial_mode_with_team_key(client,
notify_db,
notify_db_session,
to_email,
mocker):
apply_async = mocker.patch('app.celery.provider_tasks.send_sms_to_provider.apply_async')
service = create_sample_service(notify_db, notify_db_session, limit=2, restricted=True)
service_whitelist = create_sample_service_whitelist(notify_db, notify_db_session, service=service, email_address=to_email)
service_whitelist = create_sample_service_whitelist(notify_db, notify_db_session,
service=service, email_address=to_email)
email_template = create_sample_email_template(notify_db, notify_db_session, service=service)
assert service_whitelist.service_id == service.id
@@ -1161,16 +1160,16 @@ def test_should_not_send_email_to_whitelist_recipient_in_trial_mode_with_team_ke
@pytest.mark.parametrize('to_sms', ['07123123123'])
def test_should_send_sms_to_whitelist_recipient_in_trial_mode_with_live_key(
client,
notify_db,
notify_db_session,
to_sms,
mocker):
def test_should_send_sms_to_whitelist_recipient_in_trial_mode_with_live_key(client,
notify_db,
notify_db_session,
to_sms,
mocker):
apply_async = mocker.patch('app.celery.provider_tasks.send_sms_to_provider.apply_async')
service = create_sample_service(notify_db, notify_db_session, limit=2, restricted=True)
service_whitelist = create_sample_service_whitelist(notify_db, notify_db_session, service=service, mobile_number=to_sms)
service_whitelist = create_sample_service_whitelist(notify_db, notify_db_session,
service=service, mobile_number=to_sms)
sms_template = create_sample_template(notify_db, notify_db_session, service=service)
assert service_whitelist.service_id == service.id
@@ -1200,16 +1199,16 @@ def test_should_send_sms_to_whitelist_recipient_in_trial_mode_with_live_key(
@pytest.mark.parametrize('to_email', ['whitelist_recipient@mail.com'])
def test_should_send_email_to_whitelist_recipient_in_trial_mode_with_live_key(
client,
notify_db,
notify_db_session,
to_email,
mocker):
def test_should_send_email_to_whitelist_recipient_in_trial_mode_with_live_key(client,
notify_db,
notify_db_session,
to_email,
mocker):
apply_async = mocker.patch('app.celery.provider_tasks.send_email_to_provider.apply_async')
service = create_sample_service(notify_db, notify_db_session, limit=2, restricted=True)
service_whitelist = create_sample_service_whitelist(notify_db, notify_db_session, service=service, email_address=to_email)
service_whitelist = create_sample_service_whitelist(notify_db, notify_db_session,
service=service, email_address=to_email)
email_template = create_sample_email_template(notify_db, notify_db_session, service=service)
assert service_whitelist.service_id == service.id

View File

@@ -20,6 +20,7 @@ def test_get_whitelist_returns_data(client, sample_service_whitelist):
'phone_numbers': []
}
def test_get_whitelist_separates_emails_and_phones(client, sample_service):
dao_add_and_commit_whitelisted_contacts([
ServiceWhitelist.from_string(sample_service.id, EMAIL_TYPE, 'service@example.com'),
@@ -71,6 +72,7 @@ def test_update_whitelist_replaces_old_whitelist(client, sample_service_whitelis
assert whitelist[0].recipient == '07123456789'
assert whitelist[1].recipient == 'foo@bar.com'
def test_update_whitelist_doesnt_remove_old_whitelist_if_error(client, sample_service_whitelist):
data = {