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

28 statements  

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

21 

22"""Tests of things related to the GraphBuilder class.""" 

23 

24import logging 

25import unittest 

26 

27import lsst.utils.tests 

28from lsst.pipe.base.graphBuilder import DatasetQueryConstraintVariant 

29from lsst.pipe.base.tests import simpleQGraph 

30from lsst.utils.tests import temporaryDirectory 

31 

32_LOG = logging.getLogger(__name__) 

33 

34 

35class GraphBuilderTestCase(unittest.TestCase): 

36 def testDefault(self): 

37 """Simple test to verify makeSimpleQGraph can be used to make a Quantum 

38 Graph.""" 

39 with temporaryDirectory() as root: 

40 # makeSimpleQGraph calls GraphBuilder. 

41 butler, qgraph = simpleQGraph.makeSimpleQGraph(root=root) 

42 # by default makeSimpleQGraph makes a graph with 5 nodes 

43 self.assertEqual(len(qgraph), 5) 

44 constraint = DatasetQueryConstraintVariant.OFF 

45 _, qgraph2 = simpleQGraph.makeSimpleQGraph( 

46 butler=butler, datasetQueryConstraint=constraint, callPopulateButler=False 

47 ) 

48 self.assertEqual(len(qgraph2), 5) 

49 self.assertEqual(qgraph, qgraph2) 

50 constraint = DatasetQueryConstraintVariant.fromExpression("add_dataset0") 

51 _, qgraph3 = simpleQGraph.makeSimpleQGraph( 

52 butler=butler, datasetQueryConstraint=constraint, callPopulateButler=False 

53 ) 

54 self.assertEqual(qgraph2, qgraph3) 

55 

56 def testAddInstrumentMismatch(self): 

57 """Verify that a RuntimeError is raised if the instrument in the user 

58 query does not match the instrument in the pipeline.""" 

59 with temporaryDirectory() as root: 

60 pipeline = simpleQGraph.makeSimplePipeline( 

61 nQuanta=5, instrument="lsst.pipe.base.tests.simpleQGraph.SimpleInstrument" 

62 ) 

63 with self.assertRaises(RuntimeError): 

64 simpleQGraph.makeSimpleQGraph(root=root, pipeline=pipeline, userQuery="instrument = 'foo'") 

65 

66 

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

68 lsst.utils.tests.init() 

69 unittest.main()