Coverage for tests/test_cliCmdCreate.py: 71%

17 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-28 10:10 +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 """Test the butler create command-line.""" 

30 

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

32 

33 @staticmethod 

34 def defaultExpected(): 

35 return dict( 

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

37 ) 

38 

39 @staticmethod 

40 def command(): 

41 return create 

42 

43 def test_minimal(self): 

44 """Test only required parameters.""" 

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

46 

47 def test_requiredMissing(self): 

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

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

50 

51 def test_all(self): 

52 """Test all parameters.""" 

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__": 

78 unittest.main()