Hide keyboard shortcuts

Hot-keys 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

1# This unittest is not a part of sims_sed_library because introducing code into 

2# sims_sed_library would force users to install a new copy every time any 

3# upstream lsst utility code changed. This is the lowest level package that 

4# depends on sims_sed_library, so this is where we are putting the unit test. 

5 

6import unittest 

7import os 

8 

9import lsst.utils.tests 

10from lsst.utils import getPackageDir 

11 

12 

13def setup_module(module): 

14 lsst.utils.tests.init() 

15 

16 

17class SedLibraryContents(unittest.TestCase): 

18 """ 

19 This TestCase will verify that the contents of sims_sed_library were 

20 correctly loaded. 

21 """ 

22 

23 longMessage = True 

24 

25 def verify_dir(self, dir_name, n_files, min_size=10): 

26 """ 

27 verify the contents of a sims_sed_library sub directory 

28 

29 dir_name is the name of the sub-directory under sims_sed_library 

30 

31 n_files is the number of files meant to be in that directory 

32 

33 min_size is the size (in kb) that we demand all files be greater than 

34 """ 

35 msg = 'failed on %s ' % dir_name 

36 kb = 1024 

37 

38 target_dir = os.path.join(getPackageDir('sims_sed_library'), 

39 dir_name) 

40 

41 list_of_files = os.listdir(target_dir) 

42 self.assertEqual(len(list_of_files), n_files, msg=msg) 

43 

44 for file_name in list_of_files: 

45 full_name = os.path.join(target_dir, file_name) 

46 msg = 'failed on %s' % full_name 

47 self.assertGreater(os.path.getsize(full_name), min_size*kb, 

48 msg=msg) 

49 

50 def test_directories(self): 

51 self.verify_dir('starSED/kurucz', 4885) 

52 self.verify_dir('starSED/mlt', 869) 

53 self.verify_dir('starSED/phoSimMLT', 869) 

54 self.verify_dir('starSED/wDs', 1333) 

55 self.verify_dir('galaxySED', 959) 

56 self.verify_dir('agnSED', 1) 

57 self.verify_dir('igm', 30) 

58 self.verify_dir('cepheid_lc', 5, min_size=5.0) 

59 self.verify_dir('flatSED', 1) 

60 self.verify_dir('eb_lc', 1842) 

61 self.verify_dir('mflare', 50) 

62 self.verify_dir('microlens/bh_binary_source', 71, min_size=0.001) 

63 self.verify_dir('rrly_lc/RRab', 758) 

64 self.verify_dir('rrly_lc/RRc', 208) 

65 self.verify_dir('ssmSED', 26, min_size=9) 

66 

67 

68class MemoryTestClass(lsst.utils.tests.MemoryTestCase): 

69 pass 

70 

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

72 lsst.utils.tests.init() 

73 unittest.main()