Coverage for tests / tests_config / tests_simulation / test_config_time.py: 100%
25 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-09 16:40 +0100
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-09 16:40 +0100
1# SPDX-FileCopyrightText: Copyright INRIA
2#
3# SPDX-License-Identifier: LGPL-3.0-only
4#
5# Copyright INRIA
6#
7# This file is part of PhysioBlocks, a library mostly developed by the
8# [Ananke project-team](https://team.inria.fr/ananke) at INRIA.
9#
10# Authors:
11# - Colin Drieu
12# - Dominique Chapelle
13# - François Kimmig
14# - Philippe Moireau
15#
16# PhysioBlocks is free software: you can redistribute it and/or modify it under the
17# terms of the GNU Lesser General Public License as published by the Free Software
18# Foundation, version 3 of the License.
19#
20# PhysioBlocks is distributed in the hope that it will be useful, but WITHOUT ANY
21# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
22# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
23#
24# You should have received a copy of the GNU Lesser General Public License along with
25# PhysioBlocks. If not, see <https://www.gnu.org/licenses/>.
27import pytest
29from physioblocks.configuration import Configuration
30from physioblocks.configuration.constants import (
31 TIME_DURATION_TIME_VAL_ID,
32 TIME_MANAGER_ID,
33 TIME_START_TIME_VAL_ID,
34 TIME_STEP_MIN_VAL_ID,
35 TIME_STEP_TIME_VAL_ID,
36)
37from physioblocks.configuration.functions import load, save
38from physioblocks.simulation.time_manager import TimeManager
39from tests.helpers.assertion_helpers import assert_time_manager_equals
42@pytest.fixture
43def ref_time_config() -> Configuration:
44 config = Configuration(TIME_MANAGER_ID)
45 config[TIME_START_TIME_VAL_ID] = 0.0
46 config[TIME_DURATION_TIME_VAL_ID] = 1.0
47 config[TIME_STEP_TIME_VAL_ID] = 0.1
48 config[TIME_STEP_MIN_VAL_ID] = 0.01
49 return config
52@pytest.fixture
53def ref_time_manager():
54 manager = TimeManager(0.0, 1.0, 0.1, 0.01)
55 return manager
58def test_get_time_config(
59 ref_time_config: ref_time_config, ref_time_manager: ref_time_manager
60):
61 configuration = save(ref_time_manager)
62 assert ref_time_config == configuration
65def test_load_time_config(
66 ref_time_config: Configuration, ref_time_manager: TimeManager
67):
68 time_manager = TimeManager()
69 load(ref_time_config, configuration_object=time_manager)
71 assert_time_manager_equals(time_manager, ref_time_manager)