Skip to content

Commit 4814857

Browse files
authored
PPHA-749: Changed fewer to less for decreased rolling tobacco journey (#426)
# What is the change? * Updated smoking history presenter - more_or_fewer to more_or_fewer_or_less * Updated smoking_amount_form and smoking_frequency_form with updated function name * Updated tests # Why are we making this change? To use the correct language as described in prototype v1.4
2 parents fc4eded + 16a6568 commit 4814857

6 files changed

Lines changed: 104 additions & 70 deletions

File tree

features/smoking_history.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Feature: Smoking history pages
184184

185185
Then I am on "/rolling-tobacco-smoking-change"
186186
When I check "Yes, I used to smoke more than 25 grams of rolling tobacco a week"
187-
And I check "Yes, I used to smoke fewer than 25 grams of rolling tobacco a week"
187+
And I check "Yes, I used to smoke less than 25 grams of rolling tobacco a week"
188188
And I submit the form
189189

190190
Then I am on "/rolling-tobacco-smoking-increased-frequency"
@@ -205,7 +205,7 @@ Feature: Smoking history pages
205205
And I submit the form
206206

207207
Then I am on "/rolling-tobacco-smoked-decreased-amount"
208-
When I fill in "When you smoked fewer than 25 grams of rolling tobacco a week, roughly how many grams of rolling tobacco did you normally smoke a month?" with "5"
208+
When I fill in "When you smoked less than 25 grams of rolling tobacco a week, roughly how many grams of rolling tobacco did you normally smoke a month?" with "5"
209209
And I submit the form
210210

211211
Then I am on "/rolling-tobacco-smoked-decreased-years"

lung_cancer_screening/questions/forms/smoked_amount_form.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def normal_label(self):
4545

4646
def changed_label(self):
4747
return (
48-
f"When you smoked {self.presenter.more_or_fewer()} than "
48+
f"When you smoked {self.presenter.more_or_fewer_or_less()} than "
4949
f"{self.normal_presenter.to_sentence()}, "
5050
f"roughly how many {self.presenter.unit()} "
5151
f"did you normally smoke a {self.presenter.frequency()}?"
@@ -69,7 +69,7 @@ def normal_required_error_message(self):
6969
def changed_required_error_message(self):
7070
return (
7171
f"Enter the number of {self.presenter.unit()} "
72-
f"you smoked when you smoked {self.presenter.more_or_fewer()} than "
72+
f"you smoked when you smoked {self.presenter.more_or_fewer_or_less()} than "
7373
f"{self.normal_presenter.to_sentence()}"
7474
)
7575

lung_cancer_screening/questions/forms/smoking_change_form.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django import forms
22

33
from ...nhsuk_forms.choice_field import MultipleChoiceField
4-
from ..models.tobacco_smoking_history import TobaccoSmokingHistory
4+
from ..models.tobacco_smoking_history import TobaccoSmokingHistory, TobaccoSmokingHistoryTypes
55
from .mixins.smoking_form_presenter import SmokingFormPresenter
66

77

@@ -64,10 +64,13 @@ def generate_label(self, value, label):
6464
if value == TobaccoSmokingHistory.Levels.NO_CHANGE:
6565
return label
6666

67-
return (
68-
f"{TobaccoSmokingHistory.Levels(value).label} "
69-
f" than {self.presenter.to_sentence()}"
70-
)
67+
if (value == TobaccoSmokingHistory.Levels.DECREASED.value and
68+
self.tobacco_type == TobaccoSmokingHistoryTypes.ROLLING_TOBACCO):
69+
prefix = "Yes, I used to smoke less"
70+
else:
71+
prefix = TobaccoSmokingHistory.Levels(value).label
72+
73+
return f"{prefix} than {self.presenter.to_sentence()}"
7174

7275
def required_error_message(self):
7376
return (

lung_cancer_screening/questions/forms/smoking_frequency_form.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def normal_label(self):
5454

5555
def changed_label(self):
5656
return (
57-
f"When you smoked {self.presenter.more_or_fewer()} "
57+
f"When you smoked {self.presenter.more_or_fewer_or_less()} "
5858
f"than {self.normal_presenter.to_sentence()}, how often did "
5959
f"you smoke {self.presenter.human_type().lower()}?"
6060
)
@@ -77,7 +77,7 @@ def normal_required_error_message(self):
7777
def changed_required_error_message(self):
7878
return (
7979
f"Select how often you smoked {self.presenter.human_type().lower()} "
80-
f"when you smoked {self.presenter.more_or_fewer()} "
80+
f"when you smoked {self.presenter.more_or_fewer_or_less()} "
8181
f"than {self.normal_presenter.to_sentence()}"
8282
)
8383

lung_cancer_screening/questions/presenters/tobacco_smoking_history_presenter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ def have_you_smoked_or_did_you_smoke(self):
6464
return "did you smoke"
6565

6666

67-
def more_or_fewer(self):
67+
def more_or_fewer_or_less(self):
6868
if self.tobacco_smoking_history.is_increased():
6969
return "more"
7070
elif self.tobacco_smoking_history.is_decreased():
71+
if self.tobacco_smoking_history.is_rolling_tobacco():
72+
return "less"
7173
return "fewer"
7274

7375
def increased_or_decreased(self):

lung_cancer_screening/questions/tests/unit/presenters/test_tobacco_smoking_history_presenter.py

Lines changed: 87 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,17 @@
1111
)
1212
from lung_cancer_screening.questions.models.tobacco_smoking_history import TobaccoSmokingHistory
1313

14-
15-
class TestTobaccoSmokingHistoryPresenter(TestCase):
14+
class TestTobaccoSmokingHistoryPresenterAllTobaccoTypes(TestCase):
1615
def setUp(self):
1716
self.response_set = ResponseSetFactory.create()
1817
self.age_when_started_smoking_response = AgeWhenStartedSmokingResponseFactory.create(
1918
response_set=self.response_set
2019
)
2120
self.tobacco_smoking_history = TobaccoSmokingHistoryFactory.create(
22-
rolling_tobacco=True,
2321
complete=True,
2422
response_set=self.response_set
2523
)
2624

27-
def test_delegates_human_type_to_tobacco_smoking_history(self):
28-
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
29-
30-
self.assertEqual(
31-
presenter.human_type(),
32-
"Rolling tobacco"
33-
)
34-
35-
def test_url_type_returns_the_url_type_of_the_tobacco_smoking_history(self):
36-
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
37-
38-
self.assertEqual(
39-
presenter.url_type(),
40-
"rolling-tobacco"
41-
)
42-
4325
def test_duration_years_returns_not_answered_text_if_duration_years_is_not_set(self):
4426
self.tobacco_smoking_history.smoked_total_years_response = None
4527
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
@@ -67,26 +49,6 @@ def is_current_delegates_to_tobacco_smoking_history(self):
6749
)
6850

6951

70-
def test_to_sentence_returns_the_amount_of_type_per_frequency(self):
71-
self.tobacco_smoking_history.smoked_amount_response.value = 7
72-
self.tobacco_smoking_history.smoking_frequency_response.value = SmokingFrequencyValues.WEEKLY
73-
74-
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
75-
76-
self.assertEqual(
77-
presenter.to_sentence(),
78-
"7 grams of rolling tobacco a week"
79-
)
80-
81-
def test_unit_returns_the_unit_of_the_tobacco_smoking_history(self):
82-
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
83-
84-
self.assertEqual(
85-
presenter.unit(),
86-
"grams of rolling tobacco"
87-
)
88-
89-
9052
def test_smoke_or_smoked_returns_present_tense_if_current_normal_level(self):
9153
self.tobacco_smoking_history.smoking_current_response.value = True
9254
self.tobacco_smoking_history.smoking_current_response.save()
@@ -129,28 +91,17 @@ def test_frequency_returns_the_human_frequency_of_the_tobacco_smoking_history(se
12991
)
13092

13193

132-
def test_more_or_fewer_text_returns_more_if_increased_level(self):
94+
def test_more_or_fewer_or_less_text_returns_more_if_increased_level(self):
13395
self.tobacco_smoking_history.level = TobaccoSmokingHistory.Levels.INCREASED
13496
self.tobacco_smoking_history.save()
13597

13698
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
13799

138100
self.assertEqual(
139-
presenter.more_or_fewer(),
101+
presenter.more_or_fewer_or_less(),
140102
"more"
141103
)
142104

143-
def test_more_or_fewer_text_returns_fewer_if_decreased_level(self):
144-
self.tobacco_smoking_history.level = TobaccoSmokingHistory.Levels.DECREASED
145-
self.tobacco_smoking_history.save()
146-
147-
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
148-
149-
self.assertEqual(
150-
presenter.more_or_fewer(),
151-
"fewer"
152-
)
153-
154105
def test_do_or_did_returns_do_if_current_normal_level(self):
155106
self.tobacco_smoking_history.smoking_current_response.value = True
156107
self.tobacco_smoking_history.smoking_current_response.save()
@@ -207,7 +158,7 @@ def test_have_you_smoked_or_did_you_smoke_returns_did_if_not_current_normal_leve
207158
)
208159

209160

210-
def currently_or_previously_returns_currently_if_current_normal_level(self):
161+
def test_currently_or_previously_returns_currently_if_current_normal_level(self):
211162
self.tobacco_smoking_history.smoking_current_response.value = True
212163
self.tobacco_smoking_history.smoking_current_response.save()
213164

@@ -218,7 +169,7 @@ def currently_or_previously_returns_currently_if_current_normal_level(self):
218169
"currently"
219170
)
220171

221-
def currently_or_previously_returns_previously_if_not_current_normal_level(self):
172+
def test_currently_or_previously_returns_previously_if_not_current_normal_level(self):
222173
self.tobacco_smoking_history.smoking_current_response.value = False
223174
self.tobacco_smoking_history.smoking_current_response.save()
224175

@@ -229,7 +180,7 @@ def currently_or_previously_returns_previously_if_not_current_normal_level(self)
229180
"previously"
230181
)
231182

232-
def currently_or_previously_returns_previously_if_changed_level(self):
183+
def test_currently_or_previously_returns_previously_if_changed_level(self):
233184
self.tobacco_smoking_history.level = TobaccoSmokingHistory.Levels.INCREASED
234185
self.tobacco_smoking_history.save()
235186

@@ -240,7 +191,38 @@ def currently_or_previously_returns_previously_if_changed_level(self):
240191
"previously"
241192
)
242193

194+
class TestTobaccoSmokingHistoryPresenterRollingTobaccoAndPipe(TestCase):
195+
def setUp(self):
196+
self.response_set = ResponseSetFactory.create()
197+
self.age_when_started_smoking_response = AgeWhenStartedSmokingResponseFactory.create(
198+
response_set=self.response_set
199+
)
200+
self.tobacco_smoking_history = TobaccoSmokingHistoryFactory.create(
201+
complete=True,
202+
response_set=self.response_set
203+
)
204+
205+
# Tests for Rolling Tobacco
206+
def test_delegates_human_type_to_tobacco_smoking_history_rolling_tobacco(self):
207+
self.tobacco_smoking_history.type = TobaccoSmokingHistoryTypes.ROLLING_TOBACCO
208+
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
209+
210+
self.assertEqual(
211+
presenter.human_type(),
212+
"Rolling tobacco"
213+
)
214+
215+
def test_url_type_returns_the_url_type_of_the_tobacco_smoking_history_rolling_tobacco(self):
216+
self.tobacco_smoking_history.type = TobaccoSmokingHistoryTypes.ROLLING_TOBACCO
217+
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
218+
219+
self.assertEqual(
220+
presenter.url_type(),
221+
"rolling-tobacco"
222+
)
223+
243224
def test_amount_prefix_when_rolling_tobacco(self):
225+
self.tobacco_smoking_history.type = TobaccoSmokingHistoryTypes.ROLLING_TOBACCO
244226
self.tobacco_smoking_history.rolling_tobacco = True
245227
self.tobacco_smoking_history.save()
246228

@@ -251,13 +233,60 @@ def test_amount_prefix_when_rolling_tobacco(self):
251233
"grams of "
252234
)
253235

254-
def test_amount_prefix_defaults_to_empty_string(self):
236+
def test_to_sentence_returns_the_amount_of_type_per_frequency_rolling_tobacco(self):
237+
self.tobacco_smoking_history.type = TobaccoSmokingHistoryTypes.ROLLING_TOBACCO
238+
self.tobacco_smoking_history.smoked_amount_response.value = 7
239+
self.tobacco_smoking_history.smoking_frequency_response.value = SmokingFrequencyValues.WEEKLY
240+
241+
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
242+
243+
self.assertEqual(
244+
presenter.to_sentence(),
245+
"7 grams of rolling tobacco a week"
246+
)
247+
248+
def test_unit_returns_the_unit_of_the_tobacco_smoking_history_rolling_tobacco(self):
249+
self.tobacco_smoking_history.type = TobaccoSmokingHistoryTypes.ROLLING_TOBACCO
250+
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
251+
252+
self.assertEqual(
253+
presenter.unit(),
254+
"grams of rolling tobacco"
255+
)
256+
257+
def test_more_or_fewer_or_less_text_returns_less_if_decreased_level_rolling_tobacco(self):
258+
self.tobacco_smoking_history.type = TobaccoSmokingHistoryTypes.ROLLING_TOBACCO
259+
self.tobacco_smoking_history.level = TobaccoSmokingHistory.Levels.DECREASED
260+
self.tobacco_smoking_history.save()
261+
262+
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
263+
264+
self.assertEqual(
265+
presenter.more_or_fewer_or_less(),
266+
"less"
267+
)
268+
269+
# Tests for Pipe
270+
def test_more_or_fewer_or_less_text_returns_fewer_if_decreased_level_cigarettes(self):
255271
self.tobacco_smoking_history.type = TobaccoSmokingHistoryTypes.PIPE
272+
self.tobacco_smoking_history.level = TobaccoSmokingHistory.Levels.DECREASED
256273
self.tobacco_smoking_history.save()
257274

258275
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
259276

260277
self.assertEqual(
261-
presenter.amount_prefix(),
262-
""
278+
presenter.more_or_fewer_or_less(),
279+
"fewer"
280+
)
281+
282+
def test_to_sentence_returns_the_amount_of_type_per_frequency_pipe(self):
283+
self.tobacco_smoking_history.type = TobaccoSmokingHistoryTypes.PIPE
284+
self.tobacco_smoking_history.smoked_amount_response.value = 7
285+
self.tobacco_smoking_history.smoking_frequency_response.value = SmokingFrequencyValues.WEEKLY
286+
287+
presenter = TobaccoSmokingHistoryPresenter(self.tobacco_smoking_history)
288+
289+
self.assertEqual(
290+
presenter.to_sentence(),
291+
"7 full pipe loads a week"
263292
)

0 commit comments

Comments
 (0)