Coverage for tests/test_cliCmdTestIngest.py : 59%

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/>.
22"""Unit tests for daf_butler CLI ingest-raws command.
23"""
25import unittest
27from lsst.daf.butler.tests import CliCmdTestBase
28from lsst.obs.base.cli.cmd import ingest_raws
29from lsst.obs.base.cli.cmd.commands import fits_re
32class IngestRawsTestCase(CliCmdTestBase, unittest.TestCase):
34 @staticmethod
35 def defaultExpected():
36 return dict(config={},
37 config_file=None,
38 ingest_task="lsst.obs.base.RawIngestTask",
39 locations=(),
40 output_run=None,
41 regex=fits_re,
42 transfer="auto")
44 @staticmethod
45 def command():
46 return ingest_raws
48 def test_repoAndOutput(self):
49 """Test the most basic required arguments, repo and output run"""
50 self.run_test(["ingest-raws", "repo", "resources",
51 "--output-run", "out"],
52 self.makeExpected(repo="repo",
53 locations=("resources",),
54 output_run="out"))
56 def test_configMulti(self):
57 """Test config overrides"""
58 self.run_test(["ingest-raws", "repo", "resources",
59 "--output-run", "out",
60 "-c", "foo=1",
61 "--config", "bar=2,baz=3"],
62 self.makeExpected(repo="repo",
63 locations=("resources",),
64 output_run="out",
65 config=dict(foo="1", bar="2", baz="3")))
67 def test_configFile(self):
68 """Test config file override"""
69 configFile = "path/to/file.txt"
70 self.run_test(["ingest-raws", "repo", "resources",
71 "--output-run", "out",
72 "--config-file", configFile],
73 self.makeExpected(repo="repo",
74 locations=("resources",),
75 output_run="out",
76 config_file=configFile),
77 withTempFile=configFile)
79 def test_transfer(self):
80 """Test the transfer argument"""
81 self.run_test(["ingest-raws", "repo", "resources",
82 "--output-run", "out",
83 "--transfer", "symlink"],
84 self.makeExpected(repo="repo",
85 locations=("resources",),
86 output_run="out",
87 transfer="symlink"))
89 def test_ingestTask(self):
90 """Test the ingest task argument"""
91 self.run_test(["ingest-raws", "repo", "resources",
92 "--output-run", "out",
93 "--ingest-task", "foo.bar.baz"],
94 self.makeExpected(repo="repo",
95 locations=("resources",),
96 output_run="out",
97 ingest_task="foo.bar.baz"))
99 def test_locations(self):
100 """Test that the locations argument accepts multiple inputs and splits
101 commas."""
102 self.run_test(["ingest-raws", "repo", "in/directory/,in/another/dir/", "other/file.fits"],
103 self.makeExpected(repo="repo",
104 locations=("in/directory/", "in/another/dir/", "other/file.fits")))
107if __name__ == "__main__": 107 ↛ 108line 107 didn't jump to line 108, because the condition on line 107 was never true
108 unittest.main()