2020from nose .tools import assert_true , assert_false
2121from mock import patch , Mock
2222
23- from tawhiri import models
23+ from tawhiri import models , warnings
2424
2525
2626class TestModels :
@@ -71,7 +71,8 @@ def test_wind_velocity(self, timegm, make_interpolator):
7171 get_wind .return_value = 3.0 , - 5.0
7272 make_interpolator .return_value = get_wind
7373
74- f = models .make_wind_velocity (ds )
74+ w = warnings .WarningCounts ()
75+ f = models .make_wind_velocity (ds , w )
7576 dlat , dlng , zero = f (10.0 , 52.0 , 0.5 , 1000.0 )
7677 assert_equal (zero , 0.0 )
7778 get_wind .assert_called_with (0.0 , 52.0 , 0.5 , 1000.0 )
@@ -80,6 +81,8 @@ def test_wind_velocity(self, timegm, make_interpolator):
8081 assert_almost_equal (dlat , - 4.495895997e-5 )
8182 assert_almost_equal (dlng , 4.381527359e-5 )
8283
84+ assert not w .any
85+
8386 def test_burst_termination (self ):
8487 for alt in (0.0 , 5000.0 , 50000.0 ):
8588 f = models .make_burst_termination (alt )
@@ -152,6 +155,7 @@ def test_any_terminator(self):
152155 @patch ('tawhiri.models.make_drag_descent' )
153156 @patch ('tawhiri.models.make_elevation_data_termination' )
154157 def test_standard_profile (self , elev , drag , burst , wind , const , linear ):
158+ warns = warnings .WarningCounts ()
155159 wind_ds = Mock ()
156160 elev_ds = Mock ()
157161 const .return_value = 'const'
@@ -160,32 +164,35 @@ def test_standard_profile(self, elev, drag, burst, wind, const, linear):
160164 burst .return_value = 'burst'
161165 drag .return_value = 'drag'
162166 elev .return_value = 'elev'
163- model = models .standard_profile (5.0 , 30000.0 , 6.0 , wind_ds , elev_ds )
167+ model = models .standard_profile (5.0 , 30000.0 , 6.0 , wind_ds , elev_ds , warns )
164168 const .assert_called_with (5.0 )
165- wind .assert_called_with (wind_ds )
169+ wind .assert_called_with (wind_ds , warns )
166170 linear .assert_any_call (['const' , 'wind' ])
167171 burst .assert_called_with (30000.0 )
168172 drag .assert_called_with (6.0 )
169173 linear .assert_called_with (['drag' , 'wind' ])
170174 elev .assert_called_with (elev_ds )
171175 assert_equal (model , (('linear' , 'burst' ), ('linear' , 'elev' )))
176+ assert not warns .any
172177
173178 @patch ('tawhiri.models.make_linear_model' )
174179 @patch ('tawhiri.models.make_constant_ascent' )
175180 @patch ('tawhiri.models.make_wind_velocity' )
176181 @patch ('tawhiri.models.make_burst_termination' )
177182 @patch ('tawhiri.models.make_time_termination' )
178183 def test_float_profile (self , time , burst , wind , const , linear ):
184+ warns = warnings .WarningCounts ()
179185 wind_ds = Mock ()
180186 time .return_value = 'time'
181187 burst .return_value = 'burst'
182188 wind .return_value = 'wind'
183189 const .return_value = 'const'
184190 linear .return_value = 'linear'
185- model = models .float_profile (5.0 , 12000.0 , 7200.0 , wind_ds )
191+ model = models .float_profile (5.0 , 12000.0 , 7200.0 , wind_ds , warns )
186192 const .assert_called_with (5.0 )
187- wind .assert_called_with (wind_ds )
193+ wind .assert_called_with (wind_ds , warns )
188194 linear .assert_called_with (['const' , 'wind' ])
189195 burst .assert_called_with (12000.0 )
190196 time .assert_called_with (7200.0 )
191197 assert_equal (model , (('linear' , 'burst' ), ('wind' , 'time' )))
198+ assert not warns .any
0 commit comments