Coverage for tests/test_configurator.py: 42%
Shortcuts 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
Shortcuts 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#
2# LSST Data Management System
3# Copyright 2008-2012 LSST Corporation.
4#
5# This product includes software developed by the
6# LSST Project (http://www.lsst.org/).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the LSST License Statement and
19# the GNU General Public License along with this program. If not,
20# see <http://www.lsstcorp.org/LegalNotices/>.
21#
22import unittest
23import sys
24import os.path
25import time
26from lsst.ctrl.execute.configurator import Configurator
27from lsst.ctrl.execute.runOrcaParser import RunOrcaParser
28import lsst.utils.tests
31def setup_module(module):
32 lsst.utils.tests.init()
35class TestConfigurator(lsst.utils.tests.TestCase):
37 def getRemoteArgs(self):
38 sys.argv = ["configurator_test",
39 "-p", "bigboxes",
40 "-c", '"echo hello"',
41 "-i", "$CTRL_EXECUTE_DIR/tests/testfiles/inputfile",
42 "-e", "/tmp",
43 "-N", "test_set",
44 "-n", "16",
45 "-v",
46 ]
47 return sys.argv
49 def getLocalArgs(self):
50 sys.argv = ["configurator_test",
51 "-p", "lsst",
52 "-c", '"echo hello"',
53 "-i", "$CTRL_EXECUTE_DIR/tests/testfiles/inputfile",
54 "-e", "/tmp2",
55 "-N", "test_set2",
56 "-n", "12",
57 ]
58 return sys.argv
60 def getLocalWithSetupArgs(self):
61 sys.argv = ["configurator_test",
62 "-p", "lsst",
63 "-c", '"echo hello"',
64 "-i", "$CTRL_EXECUTE_DIR/tests/testfiles/inputfile",
65 "-e", "/tmp2",
66 "-N", "test_set2",
67 "-n", "12",
68 "--setup", "fake_package", "1.0",
69 ]
70 return sys.argv
72 def setup(self, args):
73 fileName = os.path.join("tests", "testfiles", "allocator-info1.py")
74 rop = RunOrcaParser(args[0])
75 args = rop.getArgs()
76 configurator = Configurator(args, fileName)
77 return configurator
79 def test1(self):
80 configurator = self.setup(self.getRemoteArgs())
81 self.assertTrue(configurator.isVerbose())
82 self.assertEqual(configurator.getParameter("EUPS_PATH"), "/tmp")
83 self.assertEqual(configurator.getParameter("USER_NAME"), "thx1138")
84 self.assertEqual(configurator.getParameter("USER_HOME"), "/home/thx1138")
86 def test2(self):
87 configurator = self.setup(self.getLocalArgs())
88 self.assertFalse(configurator.isVerbose())
89 self.assertEqual(configurator.getParameter("EUPS_PATH"), "/tmp2")
90 self.assertEqual(configurator.getParameter("USER_NAME"), "c3po")
91 self.assertEqual(configurator.getParameter("USER_HOME"), "/lsst/home/c3po")
92 self.assertEqual(configurator.getParameter("NODE_SET"), "test_set2")
93 self.assertIsNone(configurator.getParameter("KAZOO"))
95 def test3(self):
96 configurator = self.setup(self.getRemoteArgs())
97 runId1 = configurator.createRunId()
98 time.sleep(1)
99 runId2 = configurator.createRunId()
100 self.assertTrue(runId1 != runId2)
101 self.assertTrue(runId2 == configurator.getRunId())
103 def test4(self):
104 configurator = self.setup(self.getRemoteArgs())
105 self.assertIsNotNone(configurator.getSetupPackages())
108class ConfiguratorMemoryTestCase(lsst.utils.tests.MemoryTestCase):
109 pass
112if __name__ == "__main__": 112 ↛ 113line 112 didn't jump to line 113, because the condition on line 112 was never true
113 lsst.utils.tests.init()
114 unittest.main()