Coverage for marshallEngine/feeders/ztf/tests/test_images.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 yaml
7from marshallEngine.utKit import utKit
8from fundamentals import tools
9from os.path import expanduser
10home = expanduser("~")
12packageDirectory = utKit("").get_project_root()
13# settingsFile = packageDirectory + "/test_settings.yaml"
14settingsFile = home + "/git_repos/_misc_/settings/marshall/test_settings.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 PATHS TO COMMON DIRECTORIES FOR TEST DATA
27moduleDirectory = os.path.dirname(__file__)
28pathToInputDir = moduleDirectory + "/input/"
29pathToOutputDir = moduleDirectory + "/output/"
31try:
32 shutil.rmtree(pathToOutputDir)
33except:
34 pass
35# COPY INPUT TO OUTPUT DIR
36shutil.copytree(pathToInputDir, pathToOutputDir)
38# Recursively create missing directories
39if not os.path.exists(pathToOutputDir):
40 os.makedirs(pathToOutputDir)
42class test_images(unittest.TestCase):
44 def test_images_function(self):
46 from marshallEngine.feeders.ztf import images
47 cacher = images(
48 log=log,
49 settings=settings,
50 dbConn=dbConn
51 )
52 transientBucketIds, subtractedUrls, targetUrls, referenceUrls, tripletUrls = cacher._list_images_needing_cached()
53 subtractedStatus, targetStatus, referenceStatus, tripletStatus = cacher._download(
54 transientBucketIds=transientBucketIds[:10],
55 subtractedUrls=subtractedUrls[:10],
56 targetUrls=targetUrls[:10],
57 referenceUrls=referenceUrls[:10],
58 tripletUrls=tripletUrls[:10]
59 )
60 print(tripletUrls[:10])
61 cacher._update_database()
63 def test_images_function2(self):
65 from marshallEngine.feeders.ztf import images
66 cacher = images(
67 log=log,
68 settings=settings,
69 dbConn=dbConn
70 ).cache(limit=1000)
72 def test_images_function_exception(self):
74 from marshallEngine.feeders.ztf import images
75 try:
76 this = images(
77 log=log,
78 settings=settings,
79 fakeKey="break the code"
80 )
81 this.get()
82 assert False
83 except Exception as e:
84 assert True
85 print(str(e))
87 # x-print-testpage-for-pessto-marshall-web-object
89 # x-class-to-test-named-worker-function