pep8 fixes

no idea why the build/local pep8s weren't picking them up before.

also excluded import order pep8
This commit is contained in:
Leo Hemsted
2016-08-23 12:05:47 +01:00
parent 270451e7ba
commit 26d7675baa
10 changed files with 26 additions and 24 deletions

View File

@@ -113,7 +113,7 @@ def send_sms_to_provider(self, service_id, notification_id):
def provider_to_use(notification_type, notification_id): def provider_to_use(notification_type, notification_id):
active_providers_in_order = [ active_providers_in_order = [
provider for provider in get_provider_details_by_notification_type(notification_type) if provider.active provider for provider in get_provider_details_by_notification_type(notification_type) if provider.active
] ]
if not active_providers_in_order: if not active_providers_in_order:
current_app.logger.error( current_app.logger.error(

View File

@@ -87,7 +87,7 @@ def process_job(job_id):
'personalisation': { 'personalisation': {
key: personalisation.get(key) key: personalisation.get(key)
for key in template.placeholders for key in template.placeholders
} }
}) })
if template.template_type == SMS_TYPE: if template.template_type == SMS_TYPE:

View File

@@ -73,7 +73,7 @@ class MMGClient(SmsClient):
"reqType": "BULK", "reqType": "BULK",
"MSISDN": to, "MSISDN": to,
"msg": content, "msg": content,
"sender": self.from_number if sender is None else sender, "sender": self.from_number if sender is None else sender,
"cid": reference, "cid": reference,
"multi": multi "multi": multi
} }

View File

@@ -9,7 +9,7 @@ from app.models import (
EMAIL_TYPE, EMAIL_TYPE,
NOTIFICATION_STATUS_TYPES_BILLABLE, NOTIFICATION_STATUS_TYPES_BILLABLE,
KEY_TYPE_TEST KEY_TYPE_TEST
) )
def get_provider_statistics(service, **kwargs): def get_provider_statistics(service, **kwargs):

View File

@@ -201,10 +201,10 @@ def create_history(obj, history_cls=None):
# not yet have a value before insert # not yet have a value before insert
elif isinstance(prop, RelationshipProperty): elif isinstance(prop, RelationshipProperty):
if hasattr(history, prop.key+'_id'): if hasattr(history, prop.key + '_id'):
foreign_obj = getattr(obj, prop.key) foreign_obj = getattr(obj, prop.key)
# if it's a nullable relationship, foreign_obj will be None, and we actually want to record that # if it's a nullable relationship, foreign_obj will be None, and we actually want to record that
data[prop.key+'_id'] = getattr(foreign_obj, 'id', None) data[prop.key + '_id'] = getattr(foreign_obj, 'id', None)
if not obj.version: if not obj.version:
obj.version = 1 obj.version = 1

View File

@@ -427,7 +427,7 @@ class NotificationsFilterSchema(ma.Schema):
class TemplateStatisticsSchema(BaseSchema): class TemplateStatisticsSchema(BaseSchema):
template = fields.Nested(TemplateSchema, only=["id", "name", "template_type"], dump_only=True) template = fields.Nested(TemplateSchema, only=["id", "name", "template_type"], dump_only=True)
class Meta: class Meta:
model = models.TemplateStatistics model = models.TemplateStatistics

View File

@@ -6,6 +6,6 @@ pytest-cov==2.2.0
coveralls==1.1 coveralls==1.1
mock==1.0.1 mock==1.0.1
moto==0.4.19 moto==0.4.19
flex==5.6.0 flex==5.7.0
freezegun==0.3.6 freezegun==0.3.6
requests-mock==0.7.0 requests-mock==0.7.0

View File

@@ -1,4 +1,4 @@
[pep8] [pep8]
max-line-length = 120 max-line-length = 120
ignore = E402
exclude = ./migrations,./venv,./venv3 exclude = ./migrations,./venv,./venv3

View File

@@ -1110,7 +1110,7 @@ def test_set_sms_sender_for_service_rejects_invalid_characters(notify_api, sampl
'delivered': 0, 'delivered': 0,
'failed': 0 'failed': 0
}) })
], ids=['seven_days', 'today'] ], ids=['seven_days', 'today']
) )
def test_get_detailed_service(notify_db, notify_db_session, notify_api, sample_service, today_only, stats): def test_get_detailed_service(notify_db, notify_db_session, notify_api, sample_service, today_only, stats):
with notify_api.test_request_context(), notify_api.test_client() as client: with notify_api.test_request_context(), notify_api.test_client() as client:

View File

@@ -236,13 +236,14 @@ def test_send_user_sms_code(notify_api,
headers=[('Content-Type', 'application/json'), auth_header]) headers=[('Content-Type', 'application/json'), auth_header])
assert resp.status_code == 204 assert resp.status_code == 204
assert mocked.call_count == 1 assert mocked.call_count == 1
encrypted = encryption.encrypt({'template': current_app.config['SMS_CODE_TEMPLATE_ID'], encrypted = encryption.encrypt({
'template_version': 1, 'template': current_app.config['SMS_CODE_TEMPLATE_ID'],
'to': sample_user.mobile_number, 'template_version': 1,
'personalisation': { 'to': sample_user.mobile_number,
'verify_code': '11111' 'personalisation': {
} 'verify_code': '11111'
}) }
})
app.celery.tasks.send_sms.apply_async.assert_called_once_with( app.celery.tasks.send_sms.apply_async.assert_called_once_with(
([current_app.config['NOTIFY_SERVICE_ID'], ([current_app.config['NOTIFY_SERVICE_ID'],
"some_uuid", "some_uuid",
@@ -274,13 +275,14 @@ def test_send_user_code_for_sms_with_optional_to_field(notify_api,
headers=[('Content-Type', 'application/json'), auth_header]) headers=[('Content-Type', 'application/json'), auth_header])
assert resp.status_code == 204 assert resp.status_code == 204
encrypted = encryption.encrypt({'template': current_app.config['SMS_CODE_TEMPLATE_ID'], encrypted = encryption.encrypt({
'template_version': 1, 'template': current_app.config['SMS_CODE_TEMPLATE_ID'],
'to': '+441119876757', 'template_version': 1,
'personalisation': { 'to': '+441119876757',
'verify_code': '11111' 'personalisation': {
} 'verify_code': '11111'
}) }
})
assert mocked.call_count == 1 assert mocked.call_count == 1
app.celery.tasks.send_sms.apply_async.assert_called_once_with( app.celery.tasks.send_sms.apply_async.assert_called_once_with(
([current_app.config['NOTIFY_SERVICE_ID'], ([current_app.config['NOTIFY_SERVICE_ID'],