Coverage for tests/test_animation.py: 47%

32 statements  

« prev     ^ index     » next       coverage.py v7.3.3, created at 2023-12-17 15:03 +0000

1# This file is part of summit_extras. 

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 unittest 

23import tempfile 

24import os 

25import shutil 

26 

27import lsst.utils.tests 

28 

29from lsst.summit.extras.animation import Animator 

30from lsst.summit.utils.butlerUtils import makeDefaultLatissButler 

31 

32 

33class AnimationTestCase(lsst.utils.tests.TestCase): 

34 

35 @classmethod 

36 def setUpClass(cls): 

37 # test for the existence of ffmpeg and skip test if not found 

38 if shutil.which('ffmpeg') is None: 

39 raise unittest.SkipTest("Skipping tests that require ffmpeg.") 

40 

41 try: 

42 cls.butler = makeDefaultLatissButler() 

43 except FileNotFoundError: 

44 raise unittest.SkipTest("Skipping tests that require the LATISS butler repo.") 

45 

46 cls.dataIds = [{'day_obs': 20200315, 'seq_num': 120, 'detector': 0}, 

47 {'day_obs': 20200315, 'seq_num': 121, 'detector': 0}] 

48 cls.outputDir = tempfile.mkdtemp() 

49 cls.outputFilename = os.path.join(cls.outputDir, 'testAnimation.mp4') 

50 

51 def test_animation(self): 

52 """Test that the animator produces a large file without worrying about 

53 the contents? 

54 """ 

55 animator = Animator(self.butler, self.dataIds, self.outputDir, self.outputFilename, 

56 dataProductToPlot='raw', 

57 remakePngs=True, 

58 debug=False, 

59 clobberVideoAndGif=True, 

60 plotObjectCentroids=True, 

61 useQfmForCentroids=True) 

62 writtenFilename = animator.run() 

63 

64 self.assertTrue(writtenFilename == self.outputFilename) 

65 self.assertTrue(os.path.isfile(self.outputFilename)) 

66 self.assertTrue(os.path.getsize(self.outputFilename) > 10000) 

67 

68 

69class TestMemory(lsst.utils.tests.MemoryTestCase): 

70 pass 

71 

72 

73def setup_module(module): 

74 lsst.utils.tests.init() 

75 

76 

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

78 lsst.utils.tests.init() 

79 unittest.main()