|
1 | 1 | import pytest |
2 | 2 | import json |
3 | | -from loop_to_python_api.api import generate_prediction |
| 3 | +from loop_to_python_api.api import ( |
| 4 | + initialize_exception_handlers, |
| 5 | + generate_prediction, |
| 6 | + get_prediction_dates, |
| 7 | + get_glucose_effect_velocity, |
| 8 | + get_glucose_effect_velocity_dates, |
| 9 | + get_active_carbs, |
| 10 | + get_active_insulin, |
| 11 | + percent_absorption_at_percent_time, |
| 12 | + piecewise_linear_percent_rate_at_percent_time, |
| 13 | + linear_percent_rate_at_percent_time, |
| 14 | + get_dynamic_carbs_on_board, |
| 15 | +) |
4 | 16 |
|
5 | 17 |
|
6 | | -@pytest.fixture |
7 | | -def generate_prediction_input(): |
| 18 | +def get_generate_prediction_input(): |
8 | 19 | with open('python_tests/test_files/generate_prediction_input.json', 'r') as f: |
9 | 20 | return json.load(f) |
10 | 21 |
|
11 | 22 |
|
| 23 | +def get_loop_aglgorithm_input(): |
| 24 | + with open('python_tests/test_files/loop_algorithm_input.json', 'r') as f: |
| 25 | + return json.load(f) |
| 26 | + |
| 27 | + |
| 28 | +def get_dynamic_carbs_input(): |
| 29 | + with open('python_tests/test_files/dynamic_carbs_input.json', 'r') as f: |
| 30 | + return json.load(f) |
| 31 | + |
| 32 | + |
| 33 | +def test_initialize_exception_handlers(): |
| 34 | + result = initialize_exception_handlers() |
| 35 | + assert result is None # Replace with the expected result |
| 36 | + |
| 37 | + |
12 | 38 | def test_generate_prediction(): |
13 | | - prediction_input = generate_prediction_input() |
| 39 | + prediction_input = get_generate_prediction_input() |
14 | 40 | prediction_values = generate_prediction(prediction_input) |
15 | | - print(prediction_values) |
16 | | - assert prediction_values == [] |
| 41 | + assert isinstance(prediction_values, list) # Replace with the expected type or value |
| 42 | + |
| 43 | + |
| 44 | +def test_get_prediction_dates(): |
| 45 | + prediction_input = get_generate_prediction_input() |
| 46 | + prediction_dates = get_prediction_dates(prediction_input) |
| 47 | + assert isinstance(prediction_dates, list) # Replace with the expected type or value |
| 48 | + |
| 49 | + |
| 50 | +def test_get_glucose_effect_velocity(): |
| 51 | + prediction_input = get_generate_prediction_input() |
| 52 | + glucose_effect_velocity = get_glucose_effect_velocity(prediction_input) |
| 53 | + assert isinstance(glucose_effect_velocity, list) # Replace with the expected type or value |
| 54 | + |
| 55 | + |
| 56 | +def test_get_glucose_effect_velocity_dates(): |
| 57 | + prediction_input = get_generate_prediction_input() |
| 58 | + glucose_effect_velocity_dates = get_glucose_effect_velocity_dates(prediction_input) |
| 59 | + assert isinstance(glucose_effect_velocity_dates, list) # Replace with the expected type or value |
| 60 | + |
| 61 | + |
| 62 | +def test_get_active_carbs(): |
| 63 | + loop_algorithm_input = get_loop_aglgorithm_input() |
| 64 | + active_carbs = get_active_carbs(loop_algorithm_input) |
| 65 | + assert isinstance(active_carbs, float) # Replace with the expected type or value |
| 66 | + |
| 67 | + |
| 68 | +def test_get_active_insulin(): |
| 69 | + loop_algorithm_input = get_loop_aglgorithm_input() |
| 70 | + active_insulin = get_active_insulin(loop_algorithm_input) |
| 71 | + assert isinstance(active_insulin, float) # Replace with the expected type or value |
| 72 | + |
| 73 | + |
| 74 | +def test_percent_absorption_at_percent_time(): |
| 75 | + result = percent_absorption_at_percent_time(0.2) |
| 76 | + assert isinstance(result, float) # Replace with the expected type or value |
| 77 | + |
| 78 | + |
| 79 | +def test_piecewise_linear_percent_rate_at_percent_time(): |
| 80 | + result = piecewise_linear_percent_rate_at_percent_time(0.2) |
| 81 | + assert isinstance(result, float) # Replace with the expected type or value |
| 82 | + |
| 83 | + |
| 84 | +def test_linear_percent_rate_at_percent_time(): |
| 85 | + result = linear_percent_rate_at_percent_time(0.2) |
| 86 | + assert isinstance(result, float) # Replace with the expected type or value |
17 | 87 |
|
18 | 88 |
|
| 89 | +def test_get_dynamic_carbs_on_board(): |
| 90 | + dynamic_carbs_input = get_dynamic_carbs_input() |
| 91 | + dynamic_carbs_on_board = get_dynamic_carbs_on_board(dynamic_carbs_input) |
| 92 | + assert isinstance(dynamic_carbs_on_board, float) # Replace with the expected type or value |
19 | 93 |
|
20 | 94 |
|
0 commit comments