Coverage for tests/test_cliCmdConfigValidate.py: 46%
31 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-03-30 02:32 -0700
« prev ^ index » next coverage.py v6.5.0, created at 2023-03-30 02:32 -0700
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 mockFuncName = "lsst.daf.butler.cli.cmd.commands.script.configValidate"
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(
68 butler.cli,
69 [
70 "config-validate",
71 "here",
72 "--ignore",
73 "storageClasses,repoTransferFormats",
74 "-i",
75 "dimensions",
76 ],
77 )
78 self.assertEqual(result.exit_code, 0, result.stdout)
79 self.assertEqual(result.stdout, "No problems encountered with configuration.\n")
82if __name__ == "__main__":
83 unittest.main()