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 click 

27import click.testing 

28import unittest 

29 

30from lsst.daf.butler.cli import butler 

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

32from lsst.daf.butler.tests import CliCmdTestBase 

33 

34 

35class ValidateTest(CliCmdTestBase, unittest.TestCase): 

36 defaultExpected = dict() 

37 command = config_validate 

38 

39 

40class ConfigValidateUseTest(unittest.TestCase): 

41 """Test executing the command.""" 

42 

43 def testConfigValidate(self): 

44 """Test validating a valid config.""" 

45 runner = click.testing.CliRunner() 

46 with runner.isolated_filesystem(): 

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

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

49 # verify the just-created repo validates without error 

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

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

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

53 

54 def testConfigValidate_ignore(self): 

55 """Test the ignore flag""" 

56 runner = click.testing.CliRunner() 

57 with runner.isolated_filesystem(): 

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

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

60 # verify the just-created repo validates without error 

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

62 "--ignore", "storageClasses,repoTransferFormats", "-i", "dimensions"]) 

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

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

65 

66 

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

68 unittest.main()