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 unittest 

7import yaml 

8from marshallEngine.utKit import utKit 

9 

10from fundamentals import tools 

11from os.path import expanduser 

12home = expanduser("~") 

13 

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

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

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

17 

18su = tools( 

19 arguments={"settingsFile": settingsFile}, 

20 docString=__doc__, 

21 logLevel="DEBUG", 

22 options_first=False, 

23 projectName=None, 

24 defaultSettingsFile=False 

25) 

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

27settings["test"] = True 

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 

45import shutil 

46try: 

47 shutil.rmtree(settings[ 

48 "cache-directory"] + "/transients/") 

49 shutil.rmtree(settings[ 

50 "cache-directory"] + "/stats/") 

51except: 

52 pass 

53 

54 

55class test_data(unittest.TestCase): 

56 

57 def test_data_function(self): 

58 

59 allLists = [] 

60 from marshallEngine.feeders.atels.data import data 

61 ingester = data( 

62 log=log, 

63 settings=settings, 

64 dbConn=dbConn 

65 ) 

66 

67 # ADD DATA IMPORTING CODE HERE 

68 ingester._import_to_feeder_survey_table() 

69 ingester.insert_into_transientBucket() 

70 

71 def test_data_function2(self): 

72 

73 # Recursively create missing directories 

74 cache = settings["atel-directory"] 

75 settings["atel-directory"] = "/tmp/atel-archive/html" 

76 if not os.path.exists("/tmp/atel-archive/html"): 

77 os.makedirs("/tmp/atel-archive/html") 

78 

79 from marshallEngine.feeders.atels.data import data 

80 ingester = data( 

81 log=log, 

82 settings=settings, 

83 dbConn=dbConn 

84 ).ingest(withinLastDays=300) 

85 settings["atel-directory"] = cache 

86 

87 def test_data_function_exception(self): 

88 

89 from marshallEngine.feeders.atels.data import data 

90 try: 

91 this = data( 

92 log=log, 

93 settings=settings, 

94 fakeKey="break the code" 

95 ) 

96 this.get() 

97 assert False 

98 except Exception as e: 

99 assert True 

100 print(str(e)) 

101 

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

103 

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