Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1 

2# This file is part of daf_butler. 

3# 

4# Developed for the LSST Data Management System. 

5# This product includes software developed by the LSST Project 

6# (http://www.lsst.org). 

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

8# for details of code ownership. 

9# 

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

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

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

13# (at your option) any later version. 

14# 

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

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

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

18# GNU General Public License for more details. 

19# 

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

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

22 

23"""Unit tests for daf_butler CLI config-validate command. 

24""" 

25 

26import unittest 

27 

28from lsst.daf.butler.cli import butler 

29from lsst.daf.butler.cli.cmd import config_validate 

30from lsst.daf.butler.cli.utils import LogCliRunner 

31from lsst.daf.butler.tests import CliCmdTestBase 

32 

33 

34class ValidateTest(CliCmdTestBase, unittest.TestCase): 

35 

36 mockFuncName = "lsst.daf.butler.cli.cmd.commands.script.configValidate" 

37 

38 @staticmethod 

39 def defaultExpected(): 

40 return dict() 

41 

42 @staticmethod 

43 def command(): 

44 return config_validate 

45 

46 

47class ConfigValidateUseTest(unittest.TestCase): 

48 """Test executing the command.""" 

49 

50 def setUp(self): 

51 self.runner = LogCliRunner() 

52 

53 def testConfigValidate(self): 

54 """Test validating a valid config.""" 

55 with self.runner.isolated_filesystem(): 

56 result = self.runner.invoke(butler.cli, ["create", "here"]) 

57 self.assertEqual(result.exit_code, 0, result.stdout) 

58 # verify the just-created repo validates without error 

59 result = self.runner.invoke(butler.cli, ["config-validate", "here"]) 

60 self.assertEqual(result.exit_code, 0, result.stdout) 

61 self.assertEqual(result.stdout, "No problems encountered with configuration.\n") 

62 

63 def testConfigValidate_ignore(self): 

64 """Test the ignore flag""" 

65 with self.runner.isolated_filesystem(): 

66 result = self.runner.invoke(butler.cli, ["create", "here"]) 

67 self.assertEqual(result.exit_code, 0, result.stdout) 

68 # verify the just-created repo validates without error 

69 result = self.runner.invoke(butler.cli, ["config-validate", "here", 

70 "--ignore", "storageClasses,repoTransferFormats", 

71 "-i", "dimensions"]) 

72 self.assertEqual(result.exit_code, 0, result.stdout) 

73 self.assertEqual(result.stdout, "No problems encountered with configuration.\n") 

74 

75 

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

77 unittest.main()