Coverage for tests/test_cliCmd.py : 60%

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
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
23import unittest.mock
25from lsst.daf.butler.tests import CliCmdTestBase
26from lsst.daf.butler.cli.utils import Mocker
27from lsst.ctrl.mpexec.cli.pipetask import cli
28from lsst.ctrl.mpexec.cli.cmd import build, qgraph, run
29from lsst.ctrl.mpexec.cmdLineParser import _PipelineAction
32class BuildTestCase(CliCmdTestBase, unittest.TestCase):
34 def setUp(self):
35 Mocker.reset()
36 super().setUp()
38 @staticmethod
39 def defaultExpected():
40 return dict(order_pipeline=False,
41 pipeline=None,
42 pipeline_actions=list(),
43 pipeline_dot=None,
44 save_pipeline=None,
45 show=(),
46 log_level=dict())
48 @staticmethod
49 def command():
50 return build
52 cli = cli
54 def test_actionConversion(self):
55 """Verify that a pipeline action gets captured and processed correctly
56 and passed to the script function in the `pipeline_actions` list. """
58 self.run_test(["build", "-t", "foo"],
59 self.makeExpected(pipeline_actions=[_PipelineAction(action="new_task",
60 label=None,
61 value="foo")]))
64class QgraphTestCase(CliCmdTestBase, unittest.TestCase):
66 def setUp(self):
67 Mocker.reset()
68 super().setUp()
70 @staticmethod
71 def defaultExpected():
72 return dict(butler_config=None,
73 data_query=None,
74 extend_run=False,
75 input=(),
76 log_level={},
77 output=None,
78 output_run=None,
79 pipeline=None,
80 prune_replaced=None,
81 qgraph=None,
82 qgraph_dot=None,
83 replace_run=False,
84 save_qgraph=None,
85 save_single_quanta=None,
86 show=(),
87 skip_existing=False)
89 @staticmethod
90 def command():
91 return qgraph
93 cli = cli
95 def test_defaultValues(self):
96 """Test the default values match the defaultExpected values."""
97 self.run_test(["qgraph"], self.makeExpected())
100class RunTestCase(CliCmdTestBase, unittest.TestCase):
102 @staticmethod
103 def defaultExpected():
104 return dict(butler_config=None,
105 data_query=None,
106 debug=None,
107 do_raise=False,
108 extend_run=False,
109 graph_fixup=None,
110 init_only=False,
111 input=(),
112 log_level={},
113 no_versions=False,
114 output=None,
115 output_run=None,
116 processes=None,
117 profile=None,
118 prune_replaced=None,
119 qgraph=None,
120 register_dataset_types=False,
121 replace_run=False,
122 skip_existing=False,
123 skip_init_writes=False,
124 timeout=None,
125 fail_fast=False)
127 @staticmethod
128 def command():
129 return run
131 cli = cli
133 def setUp(self):
134 Mocker.reset()
135 super().setUp()
137 def test_defaultValues(self):
138 """Test the default values match the defaultExpected values."""
139 self.run_test(["run"], self.makeExpected())
141 def test_subcommandPassButlerParameters(self):
142 """Test that a butler parameter passed to `qgraph` are forwarded to
143 `run`."""
144 configFileName = "butler_config.yaml"
145 self.run_test(["qgraph", "--butler-config", configFileName, "run"],
146 (QgraphTestCase.makeExpected(butler_config=configFileName), # qgraph call
147 self.makeExpected(butler_config=configFileName)), # run call
148 withTempFile=configFileName)
151if __name__ == "__main__": 151 ↛ 152line 151 didn't jump to line 152, because the condition on line 151 was never true
152 unittest.main()