Coverage for tests/test_graphBuilder.py: 47%
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# This file is part of pipe_base.
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/>.
22"""Tests of things related to the GraphBuilder class."""
24import logging
25import unittest
27from lsst.pipe.base.tests import simpleQGraph
28from lsst.pipe.base.graphBuilder import DatasetQueryConstraintVariant
29import lsst.utils.tests
30from lsst.utils.tests import temporaryDirectory
32_LOG = logging.getLogger(__name__)
35class GraphBuilderTestCase(unittest.TestCase):
37 def testDefault(self):
38 """Simple test to verify makeSimpleQGraph can be used to make a Quantum
39 Graph."""
40 with temporaryDirectory() as root:
41 # makeSimpleQGraph calls GraphBuilder.
42 butler, qgraph = simpleQGraph.makeSimpleQGraph(root=root)
43 # by default makeSimpleQGraph makes a graph with 5 nodes
44 self.assertEqual(len(qgraph), 5)
45 constraint = DatasetQueryConstraintVariant.OFF
46 _, qgraph2 = simpleQGraph.makeSimpleQGraph(butler=butler,
47 datasetQueryConstraint=constraint,
48 callPopulateButler=False)
49 self.assertEqual(len(qgraph2), 5)
50 self.assertEqual(qgraph, qgraph2)
51 constraint = DatasetQueryConstraintVariant.fromExpression('add_dataset0')
52 _, qgraph3 = simpleQGraph.makeSimpleQGraph(butler=butler,
53 datasetQueryConstraint=constraint,
54 callPopulateButler=False)
55 self.assertEqual(qgraph2, qgraph3)
57 def testAddInstrumentMismatch(self):
58 """Verify that a RuntimeError is raised if the instrument in the user
59 query does not match the instrument in the pipeline."""
60 with temporaryDirectory() as root:
61 pipeline = simpleQGraph.makeSimplePipeline(
62 nQuanta=5,
63 instrument="lsst.pipe.base.tests.simpleQGraph.SimpleInstrument")
64 with self.assertRaises(RuntimeError):
65 simpleQGraph.makeSimpleQGraph(root=root,
66 pipeline=pipeline,
67 userQuery="instrument = 'foo'")
70if __name__ == "__main__": 70 ↛ 71line 70 didn't jump to line 71, because the condition on line 70 was never true
71 lsst.utils.tests.init()
72 unittest.main()