Hide keyboard shortcuts

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/>. 

21 

22"""Unit tests for daf_butler CLI ingest-raws command. 

23""" 

24 

25import unittest 

26 

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 

30 

31 

32class IngestRawsTestCase(CliCmdTestBase, unittest.TestCase): 

33 

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 processes=1, 

42 regex=fits_re, 

43 transfer="auto") 

44 

45 @staticmethod 

46 def command(): 

47 return ingest_raws 

48 

49 def test_repoAndOutput(self): 

50 """Test the most basic required arguments, repo and output run""" 

51 self.run_test(["ingest-raws", "repo", "resources", 

52 "--output-run", "out"], 

53 self.makeExpected(repo="repo", 

54 locations=("resources",), 

55 output_run="out")) 

56 

57 def test_configMulti(self): 

58 """Test config overrides""" 

59 self.run_test(["ingest-raws", "repo", "resources", 

60 "--output-run", "out", 

61 "-c", "foo=1", 

62 "--config", "bar=2,baz=3"], 

63 self.makeExpected(repo="repo", 

64 locations=("resources",), 

65 output_run="out", 

66 config=dict(foo="1", bar="2", baz="3"))) 

67 

68 def test_configFile(self): 

69 """Test config file override""" 

70 configFile = "path/to/file.txt" 

71 self.run_test(["ingest-raws", "repo", "resources", 

72 "--output-run", "out", 

73 "--config-file", configFile], 

74 self.makeExpected(repo="repo", 

75 locations=("resources",), 

76 output_run="out", 

77 config_file=configFile), 

78 withTempFile=configFile) 

79 

80 def test_transfer(self): 

81 """Test the transfer argument""" 

82 self.run_test(["ingest-raws", "repo", "resources", 

83 "--output-run", "out", 

84 "--transfer", "symlink"], 

85 self.makeExpected(repo="repo", 

86 locations=("resources",), 

87 output_run="out", 

88 transfer="symlink")) 

89 

90 def test_ingestTask(self): 

91 """Test the ingest task argument""" 

92 self.run_test(["ingest-raws", "repo", "resources", 

93 "--output-run", "out", 

94 "--ingest-task", "foo.bar.baz"], 

95 self.makeExpected(repo="repo", 

96 locations=("resources",), 

97 output_run="out", 

98 ingest_task="foo.bar.baz")) 

99 

100 def test_locations(self): 

101 """Test that the locations argument accepts multiple inputs and splits 

102 commas.""" 

103 self.run_test(["ingest-raws", "repo", "in/directory/,in/another/dir/", "other/file.fits"], 

104 self.makeExpected(repo="repo", 

105 locations=("in/directory/", "in/another/dir/", "other/file.fits"))) 

106 

107 

108if __name__ == "__main__": 108 ↛ 109line 108 didn't jump to line 109, because the condition on line 108 was never true

109 unittest.main()