Coverage for tests/test_animation.py: 47%

32 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-19 06:13 -0700

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 os 

23import shutil 

24import tempfile 

25import unittest 

26 

27import lsst.utils.tests 

28from lsst.summit.extras.animation import Animator 

29from lsst.summit.utils.butlerUtils import makeDefaultLatissButler 

30 

31 

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

33 @classmethod 

34 def setUpClass(cls): 

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

36 if shutil.which("ffmpeg") is None: 

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

38 

39 try: 

40 cls.butler = makeDefaultLatissButler() 

41 except FileNotFoundError: 

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

43 

44 cls.dataIds = [ 

45 {"day_obs": 20200315, "seq_num": 120, "detector": 0}, 

46 {"day_obs": 20200315, "seq_num": 121, "detector": 0}, 

47 ] 

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( 

56 self.butler, 

57 self.dataIds, 

58 self.outputDir, 

59 self.outputFilename, 

60 dataProductToPlot="raw", 

61 remakePngs=True, 

62 debug=False, 

63 clobberVideoAndGif=True, 

64 plotObjectCentroids=True, 

65 useQfmForCentroids=True, 

66 ) 

67 writtenFilename = animator.run() 

68 

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

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

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

72 

73 

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

75 pass 

76 

77 

78def setup_module(module): 

79 lsst.utils.tests.init() 

80 

81 

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

83 lsst.utils.tests.init() 

84 unittest.main()