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 

10from docopt import docopt 

11from marshallEngine import cl_utils 

12doc = cl_utils.__doc__ 

13home = expanduser("~") 

14 

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

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

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

18 

19su = tools( 

20 arguments={"settingsFile": settingsFile}, 

21 docString=__doc__, 

22 logLevel="DEBUG", 

23 options_first=False, 

24 projectName=None, 

25 defaultSettingsFile=False 

26) 

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

28 

29# SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA 

30moduleDirectory = os.path.dirname(__file__) 

31pathToInputDir = moduleDirectory + "/input/" 

32pathToOutputDir = moduleDirectory + "/output/" 

33 

34try: 

35 shutil.rmtree(pathToOutputDir) 

36except: 

37 pass 

38# COPY INPUT TO OUTPUT DIR 

39shutil.copytree(pathToInputDir, pathToOutputDir) 

40 

41# Recursively create missing directories 

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

43 os.makedirs(pathToOutputDir) 

44 

45 # marshall lightcurve < transientBucketId > [-s < pathToSettingsFile > ] 

46 

47 

48class test_cl_utils(unittest.TestCase): 

49 

50 # def test_01_cl(self): 

51 

52 # pathToSettingsFile = settingsFile 

53 # # TEST CL-OPTIONS 

54 # command = "marshall init" 

55 # args = docopt(doc, command.split(" ")[1:]) 

56 # cl_utils.main(args) 

57 

58 # command = "marshall clean -s %(pathToSettingsFile)s" % locals() 

59 # args = docopt(doc, command.split(" ")[1:]) 

60 # cl_utils.main(args) 

61 

62 # def test_02_cl(self): 

63 

64 # pathToSettingsFile = settingsFile 

65 # command = "marshall import atlas 1 -s %(pathToSettingsFile)s" % locals() 

66 # args = docopt(doc, command.split(" ")[1:]) 

67 # cl_utils.main(args) 

68 

69 # def test_03_cl(self): 

70 

71 # pathToSettingsFile = settingsFile 

72 # command = "marshall import panstarrs 1 -s %(pathToSettingsFile)s" % locals( 

73 # ) 

74 # args = docopt(doc, command.split(" ")[1:]) 

75 # cl_utils.main(args) 

76 

77 def test_04_cl(self): 

78 

79 pathToSettingsFile = settingsFile 

80 command = "marshall import tns 1 -s %(pathToSettingsFile)s" % locals() 

81 args = docopt(doc, command.split(" ")[1:]) 

82 cl_utils.main(args) 

83 

84 def test_05_cl(self): 

85 

86 pathToSettingsFile = settingsFile 

87 command = "marshall import useradded 1 -s %(pathToSettingsFile)s" % locals( 

88 ) 

89 args = docopt(doc, command.split(" ")[1:]) 

90 cl_utils.main(args) 

91 

92 def test_06_cl(self): 

93 

94 pathToSettingsFile = settingsFile 

95 command = "marshall import ztf 1 -s %(pathToSettingsFile)s" % locals() 

96 args = docopt(doc, command.split(" ")[1:]) 

97 cl_utils.main(args) 

98 

99 def test_07_cl(self): 

100 

101 pathToSettingsFile = settingsFile 

102 command = "marshall lightcurve 1 -s %(pathToSettingsFile)s" % locals() 

103 args = docopt(doc, command.split(" ")[1:]) 

104 cl_utils.main(args) 

105 

106 return 

107 

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