Coverage for tests/test_cliCmdCreate.py: 67%

19 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-02-01 10:04 +0000

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 

22import unittest 

23 

24from lsst.daf.butler.cli.cmd import create 

25from lsst.daf.butler.tests import CliCmdTestBase 

26 

27 

28class CreateTest(CliCmdTestBase, unittest.TestCase): 

29 

30 mockFuncName = "lsst.daf.butler.cli.cmd.commands.script.createRepo" 

31 

32 @staticmethod 

33 def defaultExpected(): 

34 return dict( 

35 repo=None, seed_config=None, dimension_config=None, standalone=False, override=False, outfile=None 

36 ) 

37 

38 @staticmethod 

39 def command(): 

40 return create 

41 

42 def test_minimal(self): 

43 """Test only required parameters.""" 

44 self.run_test(["create", "here"], self.makeExpected(repo="here")) 

45 

46 def test_requiredMissing(self): 

47 """Test that if the required parameter is missing it fails""" 

48 self.run_missing(["create"], r"Error: Missing argument ['\"]REPO['\"].") 

49 

50 def test_all(self): 

51 """Test all parameters.""" 

52 

53 self.run_test( 

54 [ 

55 "create", 

56 "here", 

57 "--seed-config", 

58 "foo", 

59 "--dimension-config", 

60 "/bar/dim.yaml", 

61 "--standalone", 

62 "--override", 

63 "--outfile", 

64 "bar", 

65 ], 

66 self.makeExpected( 

67 repo="here", 

68 seed_config="foo", 

69 dimension_config="/bar/dim.yaml", 

70 standalone=True, 

71 override=True, 

72 outfile="bar", 

73 ), 

74 ) 

75 

76 

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

78 unittest.main()