Coverage for tests / tests_config / tests_description / test_config_boundary_condition.py: 100%

25 statements  

« 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/>. 

26 

27import pytest 

28 

29from physioblocks.configuration import Configuration 

30from physioblocks.configuration.constants import CONDITION_NAME_ID, CONDITION_TYPE_ID 

31from physioblocks.configuration.functions import load, save 

32from physioblocks.description.nets import BOUNDARY_CONDITION_ID, BoundaryCondition 

33 

34CONDITION_TYPE = "condition_type" 

35CONDITION_ID = "condition_id" 

36 

37 

38@pytest.fixture 

39def ref_config() -> Configuration: 

40 config = Configuration(BOUNDARY_CONDITION_ID) 

41 

42 config[CONDITION_TYPE_ID] = CONDITION_TYPE 

43 config[CONDITION_NAME_ID] = CONDITION_ID 

44 

45 return config 

46 

47 

48@pytest.fixture 

49def ref_condition() -> BoundaryCondition: 

50 return BoundaryCondition(CONDITION_TYPE, CONDITION_ID) 

51 

52 

53class TestBoundaryConditionConfiguration: 

54 def test_save_boundary_condition_config( 

55 self, ref_config: Configuration, ref_condition: BoundaryCondition 

56 ): 

57 configuration = save(ref_condition) 

58 assert ref_config == configuration 

59 

60 def test_load_boundary_condition_config(self, ref_config: Configuration): 

61 condition = load(ref_config) 

62 

63 assert isinstance(condition, BoundaryCondition) 

64 assert condition.condition_id == CONDITION_ID 

65 assert condition.condition_type == CONDITION_TYPE