Coverage for tests/test_cliCmdConfigValidate.py: 46%
33 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-10 02:33 -0800
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-10 02:33 -0800
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):
35 mockFuncName = "lsst.daf.butler.cli.cmd.commands.script.configValidate"
37 @staticmethod
38 def defaultExpected():
39 return dict()
41 @staticmethod
42 def command():
43 return config_validate
46class ConfigValidateUseTest(unittest.TestCase):
47 """Test executing the command."""
49 def setUp(self):
50 self.runner = LogCliRunner()
52 def testConfigValidate(self):
53 """Test validating a valid config."""
54 with self.runner.isolated_filesystem():
55 result = self.runner.invoke(butler.cli, ["create", "here"])
56 self.assertEqual(result.exit_code, 0, result.stdout)
57 # verify the just-created repo validates without error
58 result = self.runner.invoke(butler.cli, ["config-validate", "here"])
59 self.assertEqual(result.exit_code, 0, result.stdout)
60 self.assertEqual(result.stdout, "No problems encountered with configuration.\n")
62 def testConfigValidate_ignore(self):
63 """Test the ignore flag"""
64 with self.runner.isolated_filesystem():
65 result = self.runner.invoke(butler.cli, ["create", "here"])
66 self.assertEqual(result.exit_code, 0, result.stdout)
67 # verify the just-created repo validates without error
68 result = self.runner.invoke(
69 butler.cli,
70 [
71 "config-validate",
72 "here",
73 "--ignore",
74 "storageClasses,repoTransferFormats",
75 "-i",
76 "dimensions",
77 ],
78 )
79 self.assertEqual(result.exit_code, 0, result.stdout)
80 self.assertEqual(result.stdout, "No problems encountered with configuration.\n")
83if __name__ == "__main__": 83 ↛ 84line 83 didn't jump to line 84, because the condition on line 83 was never true
84 unittest.main()