Coverage for python / lsst / ctrl / bps / tests / config_test_utils.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-18 08:47 +0000

1# This file is part of ctrl_bps. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This software is dual licensed under the GNU General Public License and also 

10# under a 3-clause BSD license. Recipients may choose which of these licenses 

11# to use; please see the files gpl-3.0.txt and/or bsd_license.txt, 

12# respectively. If you choose the GPL option then the following text applies 

13# (but note that there is still no warranty even if you opt for BSD instead): 

14# 

15# This program is free software: you can redistribute it and/or modify 

16# it under the terms of the GNU General Public License as published by 

17# the Free Software Foundation, either version 3 of the License, or 

18# (at your option) any later version. 

19# 

20# This program is distributed in the hope that it will be useful, 

21# but WITHOUT ANY WARRANTY; without even the implied warranty of 

22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

23# GNU General Public License for more details. 

24# 

25# You should have received a copy of the GNU General Public License 

26# along with this program. If not, see <https://www.gnu.org/licenses/>. 

27"""BpsConfig-related utilities to support ctrl_bps testing.""" 

28 

29__all__ = ["generate_config_1", "generate_config_2", "generate_config_all"] 

30 

31from typing import Any 

32 

33 

34def generate_config_1(param1: int, param2: int = -1, param3: int = -2) -> dict[str, Any]: 

35 """Return a dictionary for updating a config in unit tests. 

36 

37 Parameters 

38 ---------- 

39 param1 : `int` 

40 First param. 

41 param2 : `int`, optional 

42 Second param. Defaults to -1. 

43 param3 : `int`, optional 

44 Third param. Defaults to -2. 

45 

46 Returns 

47 ------- 

48 results : `dict` [`str`, `~typing.Any`] 

49 The mocked results. 

50 """ 

51 results = {"gencfg_1": param1, "gencfg_2": param2, "gencfg_3": param3, "p4": 41} 

52 return results 

53 

54 

55def generate_config_2(param1: int, param2: int = -3, param3: int = -4) -> dict[str, Any]: 

56 """Return a dictionary for updating a config in unit tests. 

57 

58 Parameters 

59 ---------- 

60 param1 : `int` 

61 First param. 

62 param2 : `int`, optional 

63 Second param. Defaults to -3. 

64 param3 : `int`, optional 

65 Third param. Defaults to -4. 

66 

67 Returns 

68 ------- 

69 results : `dict` [`str`, `~typing.Any`] 

70 The mocked results. 

71 """ 

72 results = {"gencfg_4": param1, "gencfg_5": param2, "gencfg_6": param3, "p4": 42} 

73 return results 

74 

75 

76def generate_config_all(param1: str, param2: int = -5, param3: int = -6) -> dict[str, Any]: 

77 """Return a dictionary for updating multiple sections in a config. 

78 

79 Parameters 

80 ---------- 

81 param1 : `str` 

82 First param. 

83 param2 : `int`, optional 

84 Second param. Defaults to -2. 

85 param3 : `int`, optional 

86 Third param. Defaults to -5. 

87 

88 Returns 

89 ------- 

90 results : `dict` [`str`, `~typing.Any`] 

91 The mocked results. 

92 """ 

93 results = { 

94 "genall_1": param1, 

95 "pipetask": {"ptask1": {"genall_2": param2}}, 

96 "finalJob": {"genall_3": param3}, 

97 } 

98 return results 

99 

100 

101def generate_value_1(param1: int) -> str: 

102 """Return a string for updating a config value in unit tests. 

103 

104 Parameters 

105 ---------- 

106 param1 : `int` 

107 First param. 

108 

109 Returns 

110 ------- 

111 results : `str` 

112 The mocked result. 

113 """ 

114 return f"-c val2:{param1}"