Coverage for tests/test_cliCmdConvert.py: 68%

21 statements  

« prev     ^ index     » next       coverage.py v6.4.2, created at 2022-07-16 02:16 -0700

1# This file is part of daf_butler. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (http://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 program is free software: you can redistribute it and/or modify 

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

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

12# (at your option) any later version. 

13# 

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

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

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

17# GNU General Public License for more details. 

18# 

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

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

21 

22"""Unit tests for daf_butler CLI convert command. 

23""" 

24 

25import unittest 

26 

27from lsst.daf.butler.tests import CliCmdTestBase 

28from lsst.obs.base.cli.cmd import convert 

29 

30 

31class ConvertTestCase(CliCmdTestBase, unittest.TestCase): 

32 

33 mockFuncName = "lsst.obs.base.cli.cmd.commands.script.convert" 

34 

35 @staticmethod 

36 def defaultExpected(): 

37 return dict( 

38 skymap_name=None, 

39 skymap_config=None, 

40 calibs=None, 

41 reruns=(), 

42 transfer="auto", 

43 processes=1, 

44 config_file=None, 

45 ) 

46 

47 @staticmethod 

48 def command(): 

49 return convert 

50 

51 def test_repoInstrGen2root(self): 

52 """Test the most basic required arguments.""" 

53 self.run_test( 

54 ["convert", "here", "--gen2root", "from"], self.makeExpected(repo="here", gen2root="from") 

55 ) 

56 

57 def test_all(self): 

58 """Test all the arguments.""" 

59 self.run_test( 

60 [ 

61 "convert", 

62 "here", 

63 "--gen2root", 

64 "from", 

65 "--skymap-name", 

66 "sky", 

67 "--skymap-config", 

68 "/path/to/config", 

69 "--calibs", 

70 "path/to/calib/repo", 

71 "--reruns", 

72 "one,two", 

73 "--reruns", 

74 "three", 

75 "--transfer", 

76 "symlink", 

77 "--processes", 

78 1, 

79 "--config-file", 

80 "/path/to/config", 

81 ], 

82 self.makeExpected( 

83 repo="here", 

84 gen2root="from", 

85 skymap_name="sky", 

86 skymap_config="/path/to/config", 

87 calibs="path/to/calib/repo", 

88 reruns=("one", "two", "three"), 

89 transfer="symlink", 

90 processes=1, 

91 config_file="/path/to/config", 

92 ), 

93 ) 

94 

95 def test_missing(self): 

96 """test a missing argument""" 

97 self.run_missing(["convert"], "Missing argument ['\"]REPO['\"]") 

98 self.run_missing(["convert", "here"], "Missing option ['\"]--gen2root['\"]") 

99 

100 

101if __name__ == "__main__": 101 ↛ 102line 101 didn't jump to line 102, because the condition on line 101 was never true

102 unittest.main()