Coverage for soxspipe/recipes/tests/test__base_recipe_.py: 0%

# Coverage for soxspipe/recipes/tests/test__base_recipe_.py : 0%

## 49 statements 0 run 49 missing 0 excluded

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 from __future__ import print_function

2 from builtins import str

3 import os

4 import unittest

5 import shutil

6 import unittest

7 import yaml

8 from soxspipe.utKit import utKit

9 from fundamentals import tools

10 from os.path import expanduser

11 home = expanduser("~")

12

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

14 settingsFile = packageDirectory + "/test_settings.yaml"

15# settingsFile = home + "/.config/soxspipe.recipes/soxspipe.recipes.yaml"

16 su = tools(

17 arguments={"settingsFile": settingsFile},

18 docString=__doc__,

19 logLevel="DEBUG",

20 options_first=False,

21 projectName=None,

22 defaultSettingsFile=False

23)

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

25

26# SETUP AND TEARDOWN FIXTURE FUNCTIONS FOR THE ENTIRE MODULE

27 moduleDirectory = os.path.dirname(__file__)

28 utKit = utKit(moduleDirectory)

29 log, dbConn, pathToInputDir, pathToOutputDir = utKit.setupModule()

30 utKit.tearDownModule()

31

32 try:

33 shutil.rmtree(pathToOutputDir)

34 except:

35 pass

36# COPY INPUT TO OUTPUT DIR

37 shutil.copytree(pathToInputDir, pathToOutputDir)

38

39# Recursively create missing directories

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

41 os.makedirs(pathToOutputDir)

42

43# xt-setup-unit-testing-files-and-folders

44

45

46 class test__base_recipe_(unittest.TestCase):

47

48 def test__base_recipe__function(self):

49

50 framePath = settings["test-data-root"] + \

51 "/xshooter-mbias/uvb/XSHOO.2019-07-03T10:40:24.434.fits"

52 interMediatePath = settings["intermediate-data-root"]

53 from soxspipe.recipes import _base_recipe_

54 recipe = _base_recipe_(

55 log=log,

56 settings=settings

57 )

58

59 from soxspipe.commonutils import detector_lookup

60 recipe.detectorParams = detector_lookup(

61 log=log,

62 settings=settings

63 ).get("UVB")

64 recipe.detectorParams["gain"] = 1.75

65 recipe.detectorParams["ron"] = 4.5

66 recipe.arm = "UVB"

67

68 preFrame = recipe._prepare_single_frame(frame=framePath)

69

70 # NOW TRY SAVING

71 preFrame = recipe._prepare_single_frame(frame=framePath, save=settings[

72 "save-intermediate-products"])

73

74 # NOW CLEAN UP

75 recipe.clean_up()

76

77 def test__base_recipe__function_exception(self):

78

79 from soxspipe.recipes import _base_recipe_

80 try:

81 this = _base_recipe_(

82 log=log,

83 settings=settings,

84 fakeKey="break the code"

85 )

86 this.get()

87 assert False

88 except Exception as e:

89 assert True

90 print(str(e))

91

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

93

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