Coverage for soxspipe/commonutils/tests/test_detect_continuum.py: 89%

# Coverage for soxspipe/commonutils/tests/test_detect_continuum.py : 89%

## 46 statements 41 run 5 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 from astropy.nddata import CCDData

13 from astropy import units as u

14

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

16 settingsFile = packageDirectory + "/test_settings.yaml"

17# settingsFile = home + \

18# "/git_repos/_misc_/settings/soxspipe/test_settings.yaml"

19

20 su = tools(

21 arguments={"settingsFile": settingsFile},

22 docString=__doc__,

23 logLevel="DEBUG",

24 options_first=False,

25 projectName=None,

26 defaultSettingsFile=False

27)

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

29

30# SETUP PATHS TO COMMON DIRECTORIES FOR TEST DATA

31 moduleDirectory = os.path.dirname(__file__)

32 pathToInputDir = moduleDirectory + "/input/"

33 pathToOutputDir = moduleDirectory + "/output/"

34

35 try:

36 shutil.rmtree(pathToOutputDir)

37 except:

38 pass

39# COPY INPUT TO OUTPUT DIR

40 shutil.copytree(pathToInputDir, pathToOutputDir)

41

42# Recursively create missing directories

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

44 os.makedirs(pathToOutputDir)

45

46

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

48

49

50 class test_detect_continuum(unittest.TestCase):

51

52 def test_detect_continuum_function(self):

53 pinholeFlatPath = "~/xshooter-pipeline-data/unittest_data/detect_continuum/order_definition_NIR_calibrated.fits"

54 dispersion_map = "~/xshooter-pipeline-data/unittest_data/detect_continuum/single_pinhole_NIR_disp_map.csv"

55 home = expanduser("~")

56 pinholeFlatPath = pinholeFlatPath.replace("~", home)

57

58 pinholeFlat = CCDData.read(pinholeFlatPath, hdu=0, unit=u.electron, hdu_uncertainty='ERRS',

59 hdu_mask='QUAL', hdu_flags='FLAGS', key_uncertainty_type='UTYPE')

60

61 from soxspipe.commonutils import detect_continuum

62 this = detect_continuum(

63 log=log,

64 pinholeFlat=pinholeFlat,

65 dispersion_map=dispersion_map,

66 settings=settings

67 )

68 this.get()

69

70 def test_detect_continuum_function_exception(self):

71

72 from soxspipe.commonutils import detect_continuum

73 try:

74 this = detect_continuum(

75 log=log,

76 settings=settings,

77 fakeKey="break the code"

78 )

79 this.get()

80 assert False

81 except Exception as e:

82 assert True

83 print(str(e))

84

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

86

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