Test loading a stats file with some hard-coded data generated by this test case.
(tmp_path: Path)
| 106 | |
| 107 | |
| 108 | def test_load_hardcoded_file(tmp_path: Path): |
| 109 | """Test loading a stats file with some hard-coded data generated by this test case.""" |
| 110 | |
| 111 | path = tmp_path.joinpath("stats.csv") |
| 112 | stats_manager = StatsManager() |
| 113 | with open(path, "w") as stats_file: |
| 114 | stats_writer = csv.writer(stats_file, lineterminator="\n") |
| 115 | |
| 116 | some_metric_key = "some_metric" |
| 117 | some_metric_value = 1.2 |
| 118 | some_frame_key = 100 |
| 119 | base_timecode = FrameTimecode(0, 29.97) |
| 120 | some_frame_timecode = base_timecode + some_frame_key |
| 121 | |
| 122 | # Write out a valid file. |
| 123 | stats_writer.writerow([COLUMN_NAME_FRAME_NUMBER, COLUMN_NAME_TIMECODE, some_metric_key]) |
| 124 | stats_writer.writerow( |
| 125 | [some_frame_key + 1, some_frame_timecode.get_timecode(), str(some_metric_value)] |
| 126 | ) |
| 127 | |
| 128 | stats_manager.load_from_csv(path) |
| 129 | |
| 130 | # Check that we decoded the correct values. |
| 131 | assert stats_manager.metrics_exist(some_frame_key, [some_metric_key]) |
| 132 | assert stats_manager.get_metrics(some_frame_key, [some_metric_key])[0] == pytest.approx( |
| 133 | some_metric_value |
| 134 | ) |
| 135 | |
| 136 | |
| 137 | def test_save_load_from_video(test_video_file, tmp_path: Path): |
nothing calls this directly
no test coverage detected