Coverage for tests/test_cliCmdConfigValidate.py : 47%

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
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/>.
23"""Unit tests for daf_butler CLI config-validate command.
24"""
26import unittest
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
34class ValidateTest(CliCmdTestBase, unittest.TestCase):
36 @staticmethod
37 def defaultExpected():
38 return dict()
40 @staticmethod
41 def command():
42 return config_validate
45class ConfigValidateUseTest(unittest.TestCase):
46 """Test executing the command."""
48 def setUp(self):
49 self.runner = LogCliRunner()
51 def testConfigValidate(self):
52 """Test validating a valid config."""
53 with self.runner.isolated_filesystem():
54 result = self.runner.invoke(butler.cli, ["create", "here"])
55 self.assertEqual(result.exit_code, 0, result.stdout)
56 # verify the just-created repo validates without error
57 result = self.runner.invoke(butler.cli, ["config-validate", "here"])
58 self.assertEqual(result.exit_code, 0, result.stdout)
59 self.assertEqual(result.stdout, "No problems encountered with configuration.\n")
61 def testConfigValidate_ignore(self):
62 """Test the ignore flag"""
63 with self.runner.isolated_filesystem():
64 result = self.runner.invoke(butler.cli, ["create", "here"])
65 self.assertEqual(result.exit_code, 0, result.stdout)
66 # verify the just-created repo validates without error
67 result = self.runner.invoke(butler.cli, ["config-validate", "here",
68 "--ignore", "storageClasses,repoTransferFormats",
69 "-i", "dimensions"])
70 self.assertEqual(result.exit_code, 0, result.stdout)
71 self.assertEqual(result.stdout, "No problems encountered with configuration.\n")
74if __name__ == "__main__": 74 ↛ 75line 74 didn't jump to line 75, because the condition on line 74 was never true
75 unittest.main()