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 os 

29import unittest 

30 

31from lsst.daf.butler.cli import butler 

32 

33 

34TESTDIR = os.path.abspath(os.path.dirname(__file__)) 

35 

36 

37class Suite(unittest.TestCase): 

38 

39 def testConfigValidate(self): 

40 """Test validating a valid config.""" 

41 runner = click.testing.CliRunner() 

42 with runner.isolated_filesystem(): 

43 result = runner.invoke(butler.cli, ["create", "--repo", "here"]) 

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

45 # verify the just-created repo validates without error 

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

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

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

49 

50 def testConfigValidate_ignore(self): 

51 """Test the ignore flag""" 

52 runner = click.testing.CliRunner() 

53 with runner.isolated_filesystem(): 

54 result = runner.invoke(butler.cli, ["create", "--repo", "here"]) 

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

56 # verify the just-created repo validates without error 

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

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

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

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

61 

62 

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

64 unittest.main()