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

1from __future__ import print_function 

2from builtins import str 

3import os 

4import unittest 

5import shutil 

6import yaml 

7from marshallEngine.utKit import utKit 

8from fundamentals import tools 

9from os.path import expanduser 

10home = expanduser("~") 

11 

12packageDirectory = utKit("").get_project_root() 

13# settingsFile = packageDirectory + "/test_settings.yaml" 

14settingsFile = home + "/git_repos/_misc_/settings/marshall/test_settings.yaml" 

15 

16su = tools( 

17 arguments={"settingsFile": settingsFile}, 

18 docString=__doc__, 

19 logLevel="DEBUG", 

20 options_first=False, 

21 projectName=None, 

22 defaultSettingsFile=False 

23) 

24arguments, settings, log, dbConn = su.setup() 

25 

26# SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA 

27moduleDirectory = os.path.dirname(__file__) 

28pathToInputDir = moduleDirectory + "/input/" 

29pathToOutputDir = moduleDirectory + "/output/" 

30 

31try: 

32 shutil.rmtree(pathToOutputDir) 

33except: 

34 pass 

35# COPY INPUT TO OUTPUT DIR 

36shutil.copytree(pathToInputDir, pathToOutputDir) 

37 

38# Recursively create missing directories 

39if not os.path.exists(pathToOutputDir): 

40 os.makedirs(pathToOutputDir) 

41 

42 

43class test_marshall_lightcurves(unittest.TestCase): 

44 

45 def test_marshall_lightcurves_function(self): 

46 

47 from marshallEngine.lightcurves import marshall_lightcurves, _plot_one 

48 lc = marshall_lightcurves( 

49 log=log, 

50 dbConn=dbConn, 

51 settings=settings, 

52 transientBucketIds=28121353 

53 ) 

54 filepath, currentMag, gradient = _plot_one(28121353, log, settings) 

55 

56 def test_marshall_lightcurves_function2(self): 

57 

58 from marshallEngine.lightcurves import marshall_lightcurves 

59 lc = marshall_lightcurves( 

60 log=log, 

61 dbConn=dbConn, 

62 settings=settings, 

63 transientBucketIds=[17, 21, 26, 35, 43, 48, 57, 73, 81, 85, 26787201, 26787202, 26787203, 28173350, 28173371, 28173379, 28173390, 28173405, 

64 28173408, 28173409, 28173428, 28173431, 28174061, 28174288, 28174289, 28174292, 28174296, 28174298, 28177073, 28177093, 28177094] 

65 ) 

66 this = lc.plot() 

67 print(this) 

68 

69 def test_marshall_lightcurves_function_exception(self): 

70 

71 from marshallEngine.lightcurves import marshall_lightcurves 

72 try: 

73 this = marshall_lightcurves( 

74 log=log, 

75 settings=settings, 

76 fakeKey="break the code" 

77 ) 

78 this.get() 

79 assert False 

80 except Exception as e: 

81 assert True 

82 print(str(e)) 

83 

84 # x-print-testpage-for-pessto-marshall-web-object 

85 

86 # x-class-to-test-named-worker-function