Coverage for tests/test_cliCmdCreate.py: 71%
17 statements
« prev ^ index » next coverage.py v7.2.5, created at 2023-05-18 09:13 +0000
« prev ^ index » next coverage.py v7.2.5, created at 2023-05-18 09:13 +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/>.
22import unittest
24from lsst.daf.butler.cli.cmd import create
25from lsst.daf.butler.tests import CliCmdTestBase
28class CreateTest(CliCmdTestBase, unittest.TestCase):
29 mockFuncName = "lsst.daf.butler.cli.cmd.commands.script.createRepo"
31 @staticmethod
32 def defaultExpected():
33 return dict(
34 repo=None, seed_config=None, dimension_config=None, standalone=False, override=False, outfile=None
35 )
37 @staticmethod
38 def command():
39 return create
41 def test_minimal(self):
42 """Test only required parameters."""
43 self.run_test(["create", "here"], self.makeExpected(repo="here"))
45 def test_requiredMissing(self):
46 """Test that if the required parameter is missing it fails"""
47 self.run_missing(["create"], r"Error: Missing argument ['\"]REPO['\"].")
49 def test_all(self):
50 """Test all parameters."""
52 self.run_test(
53 [
54 "create",
55 "here",
56 "--seed-config",
57 "foo",
58 "--dimension-config",
59 "/bar/dim.yaml",
60 "--standalone",
61 "--override",
62 "--outfile",
63 "bar",
64 ],
65 self.makeExpected(
66 repo="here",
67 seed_config="foo",
68 dimension_config="/bar/dim.yaml",
69 standalone=True,
70 override=True,
71 outfile="bar",
72 ),
73 )
76if __name__ == "__main__":
77 unittest.main()