Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sdc
kis_tools
Commits
ee2f3161
Commit
ee2f3161
authored
Jan 21, 2020
by
Carl Schaffer
Browse files
fixing tests for gris importer
parent
820a9e7e
Changes
5
Hide whitespace changes
Inline
Side-by-side
kis_tools/generic/SDCMongoClient.py
View file @
ee2f3161
...
...
@@ -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
()
...
...
kis_tools/generic/fits.py
View file @
ee2f3161
...
...
@@ -55,7 +55,8 @@ class FitsFile:
)
def
__getitem__
(
self
,
item
):
return
self
.
header
[
item
]
return
self
.
header
[
item
]
def
query
(
self
,
keyword
):
"""
...
...
kis_tools/gris/GrisMongoClient.py
View file @
ee2f3161
...
...
@@ -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
F
ound! Aborting
{
gdOne
.
foldername
}
"
)
print
(
f
"Errors
f
ound! Aborting
{
gdOne
.
foldername
}
"
)
errors
=
"
\n
"
.
join
(
run
.
errors
)
print
(
errors
)
errfile
.
write
(
errors
+
"
\n
"
)
...
...
kis_tools/gris/GrisRun.py
View file @
ee2f3161
...
...
@@ -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
:
...
...
kis_tools/tests/test_high_level.py
View file @
ee2f3161
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment