Coverage for tests/test_executionButler.py: 48%

21 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-15 02:49 -0700

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 for execution butler.""" 

23 

24import os 

25import unittest 

26 

27import lsst.utils.tests 

28from lsst.daf.butler import Butler 

29from lsst.pipe.base.executionButlerBuilder import buildExecutionButler 

30from lsst.pipe.base.tests import simpleQGraph 

31from lsst.utils.tests import temporaryDirectory 

32 

33TESTDIR = os.path.abspath(os.path.dirname(__file__)) 

34 

35 

36class ExecutionTestCase(unittest.TestCase): 

37 """Small bunch of tests for instantiating execution butler.""" 

38 

39 def test_simple(self) -> None: 

40 """Test buildExecutionButler with default butler config.""" 

41 with temporaryDirectory() as root: 

42 butler, qgraph = simpleQGraph.makeSimpleQGraph(root=root, inMemory=False) 

43 buildExecutionButler(butler, qgraph, os.path.join(root, "exec_butler"), butler.run) 

44 

45 def test_obscore(self) -> None: 

46 """Test buildExecutionButler with obscore table in the butler.""" 

47 with temporaryDirectory() as root: 

48 config = os.path.join(TESTDIR, "config/butler-obscore.yaml") 

49 butler = simpleQGraph.makeSimpleButler(root=root, inMemory=False, config=config) 

50 butler, qgraph = simpleQGraph.makeSimpleQGraph(butler=butler) 

51 

52 # Need a fresh butler instance to make sure it reads config from 

53 # butler.yaml, which does not have full obscore config. 

54 butler = Butler(root, run=butler.run) 

55 buildExecutionButler(butler, qgraph, os.path.join(root, "exec_butler"), butler.run) 

56 

57 

58if __name__ == "__main__": 

59 lsst.utils.tests.init() 

60 unittest.main()