Skip to content

Commit 96ad867

Browse files
Tests for interpolation
1 parent 7814234 commit 96ad867

File tree

1 file changed

+64
-4
lines changed

1 file changed

+64
-4
lines changed

tests/test_utils.py

+64-4
Original file line numberDiff line numberDiff line change
@@ -231,32 +231,92 @@ def test_write_headers(mock_print, mock_file):
231231

232232

233233
def test_check_vac_eligibility_eligible():
234-
"""Test the check_vac_eligibility function."""
234+
"""Test the check_vac_eligibility function when eligible."""
235235

236236
person = mock.Mock(status="susceptible", antivax=False, symptoms_suppressed=False)
237237

238238
assert utils.check_vac_eligibility(person) is True
239239

240240

241241
def test_check_vac_eligibility_not_eligible_status():
242-
"""Test the check_vac_eligibility function."""
242+
"""Test the check_vac_eligibility function when infected."""
243243

244244
person = mock.Mock(status="infected", antivax=False, symptoms_suppressed=False)
245245

246246
assert utils.check_vac_eligibility(person) is False
247247

248248

249249
def test_check_vac_eligibility_not_eligible_antivax():
250-
"""Test the check_vac_eligibility function."""
250+
"""Test the check_vac_eligibility function when antivax."""
251251

252252
person = mock.Mock(status="susceptible", antivax=True, symptoms_suppressed=False)
253253

254254
assert utils.check_vac_eligibility(person) is False
255255

256256

257257
def test_check_vac_eligibility_not_eligible_suppressed():
258-
"""Test the check_vac_eligibility function."""
258+
"""Test the check_vac_eligibility function when symptoms suppressed."""
259259

260260
person = mock.Mock(status="susceptible", antivax=False, symptoms_suppressed=True)
261261

262262
assert utils.check_vac_eligibility(person) is False
263+
264+
265+
def test_interpolation_single_point():
266+
"""Test the get_interpolated_lists function with a single point."""
267+
268+
data = [[0, 10.0]]
269+
interpolated_size = 5
270+
expected_result = [10.0] * interpolated_size
271+
result = utils.get_interpolated_lists(interpolated_size, data)
272+
assert result == expected_result
273+
274+
275+
def test_interpolation_linear_data():
276+
"""Test the get_interpolated_lists function with linear data."""
277+
278+
data = [[0, 0.0], [10, 10.0]]
279+
interpolated_size = 11
280+
expected_result = [float(i) for i in range(interpolated_size)]
281+
result = utils.get_interpolated_lists(interpolated_size, data)
282+
assert result == expected_result
283+
284+
285+
def test_interpolation_out_of_bounds():
286+
"""Test the get_interpolated_lists function with data outside the bounds."""
287+
288+
data = [[1, 1.0], [2, 2.0]]
289+
interpolated_size = 5
290+
expected_result = [1.0, 1.0, 2.0, 2.0, 2.0]
291+
result = utils.get_interpolated_lists(interpolated_size, data)
292+
assert result == expected_result
293+
294+
295+
def test_interpolation_with_real_numbers():
296+
"""Test the get_interpolated_lists function with real numbers."""
297+
298+
data = [[0.5, 1.5], [1.5, 2.5]]
299+
interpolated_size = 3
300+
expected_result = [1.5, 2.0, 2.5]
301+
result = utils.get_interpolated_lists(interpolated_size, data)
302+
assert result == expected_result
303+
304+
305+
def test_empty_data():
306+
"""Test the get_interpolated_lists function with empty data."""
307+
308+
data = []
309+
interpolated_size = 3
310+
311+
with pytest.raises(IndexError):
312+
_ = utils.get_interpolated_lists(interpolated_size, data)
313+
314+
315+
def test_invalid_data():
316+
"""Test the get_interpolated_lists function with invalid data."""
317+
318+
data = None
319+
interpolated_size = 3
320+
321+
with pytest.raises(IndexError):
322+
_ = utils.get_interpolated_lists(interpolated_size, data)

0 commit comments

Comments
 (0)