|
1 | 1 | from copy import deepcopy |
| 2 | +from unittest.mock import Mock |
| 3 | +import pytest |
| 4 | + |
| 5 | +from helpermodules.measurement_logging import process_log |
2 | 6 | from helpermodules.measurement_logging.process_log import ( |
3 | 7 | analyse_percentage, |
4 | 8 | _calculate_average_power, |
5 | 9 | process_entry, |
6 | 10 | get_totals, |
7 | 11 | CalculationType) |
8 | 12 |
|
| 13 | +from helpermodules.measurement_logging.process_log_testdata import (counter_jumps_forward, |
| 14 | + counter_jumps_forward_processed, |
| 15 | + regular_daily_log_entry, |
| 16 | + regular_daily_log_entry_processed) |
| 17 | + |
9 | 18 |
|
10 | 19 | def test_get_totals(daily_log_sample, daily_log_totals): |
11 | 20 | # setup and execution |
@@ -52,3 +61,19 @@ def test_convert(daily_log_entry_kw, daily_log_sample): |
52 | 61 |
|
53 | 62 | # evaluation |
54 | 63 | assert entry == daily_log_entry_kw |
| 64 | + |
| 65 | + |
| 66 | +@pytest.mark.parametrize("data, expected", [ |
| 67 | + pytest.param(counter_jumps_forward, counter_jumps_forward_processed, id="counter jumps forward"), |
| 68 | + pytest.param(regular_daily_log_entry, regular_daily_log_entry_processed, id="regular daily log entry") |
| 69 | +]) |
| 70 | +def test_get_daily_log(data, expected, monkeypatch): |
| 71 | + # setup |
| 72 | + collect_daily_log_data_mock = Mock(return_value=data) |
| 73 | + monkeypatch.setattr(process_log, "_collect_daily_log_data", collect_daily_log_data_mock) |
| 74 | + |
| 75 | + # execution |
| 76 | + daily_log_processed = process_log.get_daily_log("20250616") |
| 77 | + |
| 78 | + # evaluation |
| 79 | + assert daily_log_processed == expected |
0 commit comments