Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lung_cancer_screening/nhsuk_forms/imperial_height_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def __init__(self, *args, **kwargs):

feet_kwargs = {
"error_messages": {
'invalid': 'Feet must be in whole numbers.',
'invalid': 'Feet must be in whole numbers',
**error_messages,
},
}
inches_kwargs = {
"error_messages": {
'invalid': 'Inches must be in whole numbers.',
'invalid': 'Inches must be in whole numbers',
**error_messages,
},
}
Expand Down
12 changes: 6 additions & 6 deletions lung_cancer_screening/nhsuk_forms/imperial_weight_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ def __init__(self, *args, **kwargs):
"min_value": 0,
"max_value": 50,
"error_messages": {
'invalid': 'Stone must be in whole numbers.',
'min_value': 'Weight must be between 4 stone and 50 stone.',
'max_value': 'Weight must be between 4 stone and 50 stone.',
'invalid': 'Stone must be in whole numbers',
'min_value': 'Weight must be between 4 stone and 50 stone',
'max_value': 'Weight must be between 4 stone and 50 stone',
**error_messages,
},
}
pounds_kwargs = {
"min_value": 0,
"max_value": 13,
"error_messages": {
'invalid': 'Pounds must be in whole numbers.',
'min_value': 'Pounds must be between 0 and 13.',
'max_value': 'Pounds must be between 0 and 13.',
'invalid': 'Pounds must be in whole numbers',
'min_value': 'Pounds must be between 0 and 13',
'max_value': 'Pounds must be between 0 and 13',
**error_messages,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, *args, **kwargs):
label_classes="nhsuk-fieldset__legend--m",
coerce=lambda x: x == 'True',
error_messages={
'required': 'Select if you have been exposed to asbestos.'
'required': 'Select if you have been exposed to asbestos'
}
)

Expand Down
6 changes: 3 additions & 3 deletions lung_cancer_screening/questions/forms/date_of_birth_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def __init__(self, *args, **kwargs):
label_is_page_heading=True,
hint="For example, 15 3 1965",
error_messages={
'required': 'Enter your date of birth.',
'incomplete': 'Enter your full date of birth.',
'invalid': 'Date of birth must be a real date.'
'required': 'Enter your date of birth',
'incomplete': 'Enter your full date of birth',
'invalid': 'Date of birth must be a real date'
}
)

Expand Down
2 changes: 1 addition & 1 deletion lung_cancer_screening/questions/forms/ethnicity_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, *args, **kwargs):
label_is_page_heading=True,
hint="Your ethnicity may impact your chances of developing lung cancer.",
error_messages={
'required': 'Select your ethnic background.'
'required': 'Select your ethnic background'
}
)

Expand Down
2 changes: 1 addition & 1 deletion lung_cancer_screening/questions/forms/gender_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, *args, **kwargs):
label_is_page_heading=True,
hint="This information is used to find your NHS number and match with your GP record.",
error_messages={
'required': 'Select the option that best describes your gender.'
'required': 'Select the option that best describes your gender'
}
)

Expand Down
4 changes: 2 additions & 2 deletions lung_cancer_screening/questions/forms/imperial_height_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def __init__(self, *args, **kwargs):
required=True,
require_all_fields=False,
error_messages={
'required': 'Enter your height.',
'incomplete': 'Enter your height.'
'required': 'Enter your height',
'incomplete': 'Enter your height'
}
)

Expand Down
4 changes: 2 additions & 2 deletions lung_cancer_screening/questions/forms/imperial_weight_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def __init__(self, *args, **kwargs):
required=True,
require_all_fields=False,
error_messages={
'required': 'Enter your weight.',
'incomplete': 'Enter your weight.'
'required': 'Enter your weight',
'incomplete': 'Enter your weight'
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, *args, **kwargs):
label="Centimetres",
classes="nhsuk-input--width-4",
error_messages={
'required': 'Enter your height.',
'required': 'Enter your height',
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, *args, **kwargs):
classes="nhsuk-input--width-4",
required=True,
error_messages={
'required': 'Enter your weight.',
'required': 'Enter your weight',
}
)
def clean_weight_metric(self):
Expand Down
2 changes: 1 addition & 1 deletion lung_cancer_screening/questions/forms/sex_at_birth_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, *args, **kwargs):
label_is_page_heading=True,
hint="Your sex may impact your chances of developing lung cancer.",
error_messages={
'required': 'Select your sex at birth.'
'required': 'Select your sex at birth'
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ def test_is_invalid_when_no_option_is_selected(self):
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors["asbestos_exposure"],
["Select if you have been exposed to asbestos."]
["Select if you have been exposed to asbestos"]
)
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_is_invalid_when_no_date_is_provided(self):
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors["date_of_birth"],
["Enter your date of birth."]
["Enter your date of birth"]
)

def test_is_invalid_when_a_partial_date_is_provided(self):
Expand All @@ -48,7 +48,7 @@ def test_is_invalid_when_a_partial_date_is_provided(self):
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors["date_of_birth"],
["Enter your full date of birth."]
["Enter your full date of birth"]
)

def test_is_invalid_when_an_invalid_date_is_provided(self):
Expand All @@ -64,7 +64,7 @@ def test_is_invalid_when_an_invalid_date_is_provided(self):
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors["date_of_birth"],
["Date of birth must be a real date."]
["Date of birth must be a real date"]
)

def test_returns_a_date_type(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ def test_is_invalid_when_no_option_is_selected(self):
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors["ethnicity"],
["Select your ethnic background."]
["Select your ethnic background"]
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ def test_is_invalid_when_no_option_is_selected(self):
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors["gender"],
["Select the option that best describes your gender."]
["Select the option that best describes your gender"]
)
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_is_invalid_with_missing_data(self):
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors["height_imperial"],
["Enter your height."]
["Enter your height"]
)

def test_is_invalid_when_given_a_decimal_feet_value(self):
Expand All @@ -75,5 +75,5 @@ def test_is_invalid_when_given_a_decimal_feet_value(self):
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors["height_imperial"],
["Feet must be in whole numbers."]
["Feet must be in whole numbers"]
)
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_is_invalid_with_missing_data(self):
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors["weight_imperial"],
["Enter your weight."]
["Enter your weight"]
)

def test_is_invalid_when_given_a_decimal_stone_value(self):
Expand All @@ -74,5 +74,5 @@ def test_is_invalid_when_given_a_decimal_stone_value(self):
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors["weight_imperial"],
["Stone must be in whole numbers."]
["Stone must be in whole numbers"]
)
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_error_message_when_weight_is_empty(self):
}
)
self.assertFalse(form.is_valid())
self.assertEqual(form.errors["weight_metric"], ["Enter your weight."])
self.assertEqual(form.errors["weight_metric"], ["Enter your weight"])

def test_is_not_valid_without_any_weight_value_set(self):
form = MetricWeightForm(
Expand All @@ -51,7 +51,7 @@ def test_is_not_valid_without_any_weight_value_set(self):
}
)
self.assertFalse(form.is_valid())
self.assertEqual(form.errors, {"weight_metric": ["Enter your weight."]})
self.assertEqual(form.errors, {"weight_metric": ["Enter your weight"]})

# UAT: Error message for weight below minimum (25.4kg)
def test_error_message_when_weight_below_minimum(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ def test_is_invalid_when_no_option_is_selected(self):
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors["sex_at_birth"],
["Select your sex at birth."]
["Select your sex at birth"]
)
16 changes: 8 additions & 8 deletions tests/features/validation_errors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Feature: Validation errors
When I go to "/date-of-birth"
And I submit the form
Then I am on "/date-of-birth"
And I see a form error "Enter your date of birth."
And I see a form error "Enter your date of birth"

Scenario: Height form errors
Given I have started the questionnaire
When I go to "/height"
And I submit the form
Then I am on "/height"
And I see a form error "Enter your height."
And I see a form error "Enter your height"
When I fill in and submit my height with "139.6"
Then I am on "/height"
And I see a form error "Height must be between 139.7cm and 243.8 cm"
Expand All @@ -24,7 +24,7 @@ Feature: Validation errors
When I go to "/height?unit=imperial"
And I submit the form
Then I am on "/height?unit=imperial"
And I see a form error "Enter your height."
And I see a form error "Enter your height"
When I fill in and submit my height with "5.2" feet and "2" inches
Then I am on "/height?unit=imperial"
And I see a form error "Feet must be in whole numbers"
Expand All @@ -40,7 +40,7 @@ Feature: Validation errors
When I go to "/weight"
And I submit the form
Then I am on "/weight"
And I see a form error "Enter your weight."
And I see a form error "Enter your weight"
When I fill in and submit my weight with "25.3"
Then I am on "/weight"
And I see a form error "Weight must be between 25.4kg and 317.5kg"
Expand All @@ -53,7 +53,7 @@ Feature: Validation errors
When I go to "/weight?unit=imperial"
And I submit the form
Then I am on "/weight?unit=imperial"
And I see a form error "Enter your weight."
And I see a form error "Enter your weight"
When I fill in and submit my weight with "5.2" stone and "2" pounds
Then I am on "/weight?unit=imperial"
And I see a form error "Stone must be in whole numbers"
Expand All @@ -72,21 +72,21 @@ Feature: Validation errors
When I go to "/sex-at-birth"
And I submit the form
Then I am on "/sex-at-birth"
And I see a form error "Select your sex at birth."
And I see a form error "Select your sex at birth"

Scenario: Gender form errors
Given I have started the questionnaire
When I go to "/gender"
And I submit the form
Then I am on "/gender"
And I see a form error "Select the option that best describes your gender."
And I see a form error "Select the option that best describes your gender"

Scenario: Ethnicity form errors
Given I have started the questionnaire
When I go to "/ethnicity"
And I submit the form
Then I am on "/ethnicity"
And I see a form error "Select your ethnic background."
And I see a form error "Select your ethnic background"

Scenario: Respiratory conditions form errors
Given I have started the questionnaire
Expand Down
Loading