1111)
1212from 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