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

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://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 <https://www.gnu.org/licenses/>. 

21 

22import shlex 

23import unittest 

24 

25import lsst.utils.tests 

26from lsst.ap.pipe.make_apdb import ConfigOnlyParser 

27 

28 

29class MakeApdbParserTestSuite(lsst.utils.tests.TestCase): 

30 

31 def _parseString(self, commandLine): 

32 """Tokenize and parse a command line string. 

33 

34 Parameters 

35 ---------- 

36 commandLine : `str` 

37 a string containing Unix-style command line arguments, but not the 

38 name of the program 

39 

40 Returns 

41 ------- 

42 parsed : `argparse.Namespace` 

43 The parsed command line. 

44 """ 

45 return self.parser.parse_args(shlex.split(commandLine)) 

46 

47 def setUp(self): 

48 self.parser = ConfigOnlyParser() 

49 

50 def testExtras(self): 

51 """Verify that a command line containing extra arguments is rejected. 

52 """ 

53 args = '-c diaPipe.apdb.db_url="dummy" --id visit=42' 

54 with self.assertRaises(SystemExit): 

55 self._parseString(args) 

56 

57 def testSetValue(self): 

58 """Verify that command-line arguments get propagated. 

59 """ 

60 args = '-c diaPipe.apdb.db_url="dummy" -c diaPipe.apdb.dia_object_index=pix_id_iov' 

61 parsed = self._parseString(args) 

62 self.assertEqual(parsed.config.diaPipe.apdb.db_url, 'dummy') 

63 self.assertEqual(parsed.config.diaPipe.apdb.dia_object_index, 'pix_id_iov') 

64 

65 

66class MemoryTester(lsst.utils.tests.MemoryTestCase): 

67 pass 

68 

69 

70def setup_module(module): 

71 lsst.utils.tests.init() 

72 

73 

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

75 lsst.utils.tests.init() 

76 unittest.main()