Commit ee2f3161 authored by Carl Schaffer's avatar Carl Schaffer
Browse files

fixing tests for gris importer

parent 820a9e7e
......@@ -147,8 +147,10 @@ class SDCMongoClient(MongoClient):
def update():
# construct query to determine _id of outdated entry:
query = {"md5": md5, "metadata.filename": filename}
duplicate_id = target.find(query)[0]._id
query = {
"metadata.filename": filename}
query_result = target.find(query)
duplicate_id = query_result[0]._id
target.delete(duplicate_id)
return write()
......
......@@ -55,7 +55,8 @@ class FitsFile:
)
def __getitem__(self, item):
return self.header[item]
return self.header[item]
def query(self, keyword):
"""
......
......@@ -276,7 +276,7 @@ def fill_db(folder, server, database, errdir, force_import=False):
if len(run.errors) == 0:
gmc.write_gris_run(run)
else:
print(f"Errors Found! Aborting {gdOne.foldername}")
print(f"Errors found! Aborting {gdOne.foldername}")
errors = "\n".join(run.errors)
print(errors)
errfile.write(errors + "\n")
......
......@@ -221,6 +221,7 @@ class GrisRun(object):
res: value of given attribute if the current instance has the attribute, list of attributes for all
constituents if there is no attribute in "self"
"""
print(attribute)
if hasattr(self, attribute):
res = getattr(self, attribute)
else:
......
......@@ -9,10 +9,12 @@ from tempfile import TemporaryDirectory
from unittest.mock import patch
import kis_tools.gris.GrisMapExtractor
import kis_tools.gris.GrisMongoClient
from kis_tools.gris.GrisMongoClient import GrisMongoClient
from astropy.wcs import WCS
from kis_tools.gris.GrisFitsFile import GrisFitsFile
from kis_tools.gris import GrisMongoClient
from kis_tools.gris.GrisMongoClient import run_gris_importer
from kis_tools.headers.translate_header import main
class TestHighLevel(unittest.TestCase):
"""Class for high level testing of
......@@ -33,7 +35,7 @@ class TestHighLevel(unittest.TestCase):
cls.errdir = "/tmp/gris_testing/"
os.makedirs(cls.errdir, exist_ok=True)
gmc = GrisMongoClient.GrisMongoClient(cls.server, cls.database)
gmc = GrisMongoClient(cls.server, cls.database)
gmc.verbose = True
......@@ -130,10 +132,12 @@ class TestHighLevel(unittest.TestCase):
self.daytarget, self.server, self.database, self.errdir
)
@patch(".bin.gris_importer.open")
def test_import(self, mock_logfile):
def test_import(self):
""" test importing tool"""
test_args =["/dat/sdc/testing_data_for_importer/gris/20140426/"]
run_gris_importer(test_args)
collections = self.collections
# Drop collections to start with empty testing DB
self.clean_collections(collections)
......@@ -167,7 +171,7 @@ class TestHighLevel(unittest.TestCase):
with TemporaryDirectory() as directory:
file_out = join(directory, basename(file_in))
translate_header(file_in, file_out)
main(file_in, file_out)
file_old = GrisFitsFile(file_in)
file_new = GrisFitsFile(file_out)
nh = file_new.header
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment