Coverage for tests/test_cliCmdConfigValidate.py: 51%
31 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-21 09:55 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-21 09:55 +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/>.
22"""Unit tests for daf_butler CLI config-validate command.
23"""
25import unittest
27from lsst.daf.butler.cli import butler
28from lsst.daf.butler.cli.cmd import config_validate
29from lsst.daf.butler.cli.utils import LogCliRunner
30from lsst.daf.butler.tests import CliCmdTestBase
33class ValidateTest(CliCmdTestBase, unittest.TestCase):
34 """Test the config validation command-line."""
36 mockFuncName = "lsst.daf.butler.cli.cmd.commands.script.configValidate"
38 @staticmethod
39 def defaultExpected():
40 return dict()
42 @staticmethod
43 def command():
44 return config_validate
47class ConfigValidateUseTest(unittest.TestCase):
48 """Test executing the command."""
50 def setUp(self):
51 self.runner = LogCliRunner()
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")
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(
70 butler.cli,
71 [
72 "config-validate",
73 "here",
74 "--ignore",
75 "storageClasses,repoTransferFormats",
76 "-i",
77 "dimensions",
78 ],
79 )
80 self.assertEqual(result.exit_code, 0, result.stdout)
81 self.assertEqual(result.stdout, "No problems encountered with configuration.\n")
84if __name__ == "__main__":
85 unittest.main()