Coverage for tests / test_animation.py: 41%

35 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-01 09:04 +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 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 

30from lsst.summit.utils.utils import getSite 

31 

32 

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

34 @classmethod 

35 def setUpClass(cls): 

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

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

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

39 

40 try: 

41 if getSite() == "jenkins": 

42 raise unittest.SkipTest("Skip running butler-driven tests in Jenkins.") 

43 cls.butler = makeDefaultLatissButler() 

44 except FileNotFoundError: 

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

46 

47 cls.dataIds = [ 

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

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

50 ] 

51 cls.outputDir = tempfile.mkdtemp() 

52 cls.outputFilename = os.path.join(cls.outputDir, "testAnimation.mp4") 

53 

54 def test_animation(self): 

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

56 the contents? 

57 """ 

58 animator = Animator( 

59 self.butler, 

60 self.dataIds, 

61 self.outputDir, 

62 self.outputFilename, 

63 dataProductToPlot="raw", 

64 remakePngs=True, 

65 debug=False, 

66 clobberVideoAndGif=True, 

67 plotObjectCentroids=True, 

68 useQfmForCentroids=True, 

69 ) 

70 writtenFilename = animator.run() 

71 

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

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

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

75 

76 

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

78 pass 

79 

80 

81def setup_module(module): 

82 lsst.utils.tests.init() 

83 

84 

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

86 lsst.utils.tests.init() 

87 unittest.main()