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

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 soxspipe.utKit import utKit
9from fundamentals import tools
10from os.path import expanduser
11home = expanduser("~")
13packageDirectory = utKit("").get_project_root()
14settingsFile = packageDirectory + "/test_settings.yaml"
15# settingsFile = home + "/.config/soxspipe.recipes/soxspipe.recipes.yaml"
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()
26# SETUP AND TEARDOWN FIXTURE FUNCTIONS FOR THE ENTIRE MODULE
27moduleDirectory = os.path.dirname(__file__)
28utKit = utKit(moduleDirectory)
29log, dbConn, pathToInputDir, pathToOutputDir = utKit.setupModule()
30utKit.tearDownModule()
32try:
33 shutil.rmtree(pathToOutputDir)
34except:
35 pass
36# COPY INPUT TO OUTPUT DIR
37shutil.copytree(pathToInputDir, pathToOutputDir)
39# Recursively create missing directories
40if not os.path.exists(pathToOutputDir):
41 os.makedirs(pathToOutputDir)
43# xt-setup-unit-testing-files-and-folders
46class test__base_recipe_(unittest.TestCase):
48 def test__base_recipe__function(self):
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 )
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"
68 preFrame = recipe._prepare_single_frame(frame=framePath)
70 # NOW TRY SAVING
71 preFrame = recipe._prepare_single_frame(frame=framePath, save=settings[
72 "save-intermediate-products"])
74 # NOW CLEAN UP
75 recipe.clean_up()
77 def test__base_recipe__function_exception(self):
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))
92 # x-print-testpage-for-pessto-marshall-web-object
94 # x-class-to-test-named-worker-function