fix linter errors

This commit is contained in:
Leo Hemsted
2017-10-27 10:56:03 +01:00
parent 828c2de475
commit 0ea68f9c6d
4 changed files with 17 additions and 17 deletions

View File

@@ -506,7 +506,7 @@ class ServiceSmsSender(Form):
]
)
def validate_sms_sender(form, field):
def validate_sms_sender(self, field):
if field.data and not re.match(r'^[a-zA-Z0-9\s]+$', field.data):
raise ValidationError('Use letters and numbers only')
@@ -520,7 +520,7 @@ class ServiceLetterContactBlockForm(Form):
)
is_default = BooleanField("Set as your default address")
def validate_letter_contact_block(form, field):
def validate_letter_contact_block(self, field):
line_count = field.data.strip().count('\n')
if line_count >= 10:
raise ValidationError(

View File

@@ -80,7 +80,7 @@ def template_history(service_id):
months = [
{
'name': YYYY_MM_to_datetime(month).strftime('%B'),
'name': yyyy_mm_to_datetime(month).strftime('%B'),
'templates_used': aggregate_usage(
format_template_stats_to_list(stats.get(month)), sort_key='requested_count'
),
@@ -310,14 +310,14 @@ def format_monthly_stats_to_list(historical_stats):
return sorted((
dict(
date=key,
future=YYYY_MM_to_datetime(key) > datetime.utcnow(),
name=YYYY_MM_to_datetime(key).strftime('%B'),
future=yyyy_mm_to_datetime(key) > datetime.utcnow(),
name=yyyy_mm_to_datetime(key).strftime('%B'),
**aggregate_status_types(value)
) for key, value in historical_stats.items()
), key=lambda x: x['date'])
def YYYY_MM_to_datetime(string):
def yyyy_mm_to_datetime(string):
return datetime(int(string[0:4]), int(string[5:7]), 1)

View File

@@ -50,7 +50,7 @@ def test_get_user_phone_number_when_only_outbound_exists(mocker):
mock_get_notification.assert_called_once_with('service', 'notification')
def test_get_user_phone_number_raises_if_both_API_requests_fail(mocker):
def test_get_user_phone_number_raises_if_both_api_requests_fail(mocker):
mock_get_inbound_sms = mocker.patch(
'app.main.views.conversation.service_api_client.get_inbound_sms_by_id',
side_effect=HTTPError,

View File

@@ -31,7 +31,7 @@ valid_letter_jobs = [
send_letter_jobs_response = {"response": "Task created to send files to DVLA"}
class letter_jobs_header(IntEnum):
class LetterJobsHeader(IntEnum):
SERVICE_NAME = 0
JOB_ID = 1
NOTIFICATION_COUNT = 2
@@ -58,15 +58,15 @@ def test_get_letter_jobs_returns_list_of_all_letter_jobs(logged_in_platform_admi
for row_pos in range(len(rows)):
cols = rows[row_pos].find_all('td')
assert valid_letter_jobs[row_pos]['service_name']['name'] == cols[letter_jobs_header.SERVICE_NAME].text
assert valid_letter_jobs[row_pos]['id'] == cols[letter_jobs_header.JOB_ID].text
assert valid_letter_jobs[row_pos]['notification_count'] == int(cols[letter_jobs_header.NOTIFICATION_COUNT].text)
assert valid_letter_jobs[row_pos]['job_status'] == cols[letter_jobs_header.JOB_STATUS].text
assert valid_letter_jobs[row_pos]['service_name']['name'] == cols[LetterJobsHeader.SERVICE_NAME].text
assert valid_letter_jobs[row_pos]['id'] == cols[LetterJobsHeader.JOB_ID].text
assert valid_letter_jobs[row_pos]['notification_count'] == int(cols[LetterJobsHeader.NOTIFICATION_COUNT].text)
assert valid_letter_jobs[row_pos]['job_status'] == cols[LetterJobsHeader.JOB_STATUS].text
assert format_datetime_short(
valid_letter_jobs[row_pos]['created_at']) == cols[letter_jobs_header.CREATED_AT].text
valid_letter_jobs[row_pos]['created_at']) == cols[LetterJobsHeader.CREATED_AT].text
if not (valid_letter_jobs[row_pos]['job_status'] == 'ready to send' or
valid_letter_jobs[row_pos]['job_status'] == 'sent to dvla'):
assert 'disabled' in str(cols[letter_jobs_header.CHECKBOX])
assert 'disabled' in str(cols[LetterJobsHeader.CHECKBOX])
def test_post_letter_jobs_select_1_letter_job_submits_1_job(logged_in_platform_admin_client, mocker):
@@ -92,9 +92,9 @@ def test_post_letter_jobs_select_1_letter_job_submits_1_job(logged_in_platform_a
colr1 = rows[1].find_all('td')
colr2 = rows[2].find_all('td')
assert colr0[letter_jobs_header.TEMP_STATUS].text == "sending"
assert colr1[letter_jobs_header.TEMP_STATUS].text == ""
assert colr2[letter_jobs_header.TEMP_STATUS].text == ""
assert colr0[LetterJobsHeader.TEMP_STATUS].text == "sending"
assert colr1[LetterJobsHeader.TEMP_STATUS].text == ""
assert colr2[LetterJobsHeader.TEMP_STATUS].text == ""
message = page.find('p', attrs={'id': 'message'}).text
assert "Task created to send files to DVLA" in message