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
Andrew Leonard
kisfido
Commits
f032350e
Commit
f032350e
authored
Oct 19, 2021
by
Derek Homeier
Browse files
Test meta and binary data access via HTTP (no GridFS)
parent
f277eea8
Pipeline
#2480
passed with stage
in 3 minutes and 40 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
sdc/tests/test_client.py
View file @
f032350e
...
...
@@ -5,6 +5,7 @@ from urllib.error import HTTPError, URLError
import
json
import
astropy.units
as
u
from
astropy.io
import
fits
from
sunpy.net
import
attrs
as
a
from
sunpy.net.base_client
import
QueryResponseTable
...
...
@@ -57,6 +58,29 @@ def test_docker(client):
assert
description
[
'TELESCOPE'
]
==
'GREGOR'
assert
description
[
'BTYPE'
]
==
'phot.count'
links
=
res
[
0
][
'_embedded'
][
0
].
get
(
'links'
)
oid
=
links
[
'l1_data'
][
0
][
'$oid'
]
meta
=
json
.
loads
(
urllib
.
request
.
urlopen
(
f
"
{
_BASE_URL
}
gris_l1_data.files/
{
oid
}
"
).
read
())
assert
meta
[
'_id'
][
'$oid'
]
==
oid
hdulist
=
fits
.
open
(
f
"
{
_BASE_URL
}
gris_l1_data.files/
{
oid
}
/binary"
)
assert
hdulist
[
0
].
header
.
get
(
'TELESCOP'
)
==
'GREGOR'
assert
'2014-04-26T'
in
hdulist
[
0
].
header
.
get
(
'DATE-OBS'
)
def
test_gridfs
(
client
):
"""Test gridfs access on dockertest."""
pytest
.
xfail
(
"No GridFS on gitlab-runner"
)
import
gridfs
from
kis_tools.generic
import
get_sdc_connection
res
=
client
.
search
(
a
.
Instrument
(
"GRIS"
)
&
a
.
sdc
.
ObsName
(
'gris_20140426_000'
))
links
=
res
[
0
][
'_embedded'
][
0
].
get
(
'links'
)
file_ids
=
[
ld
[
'$oid'
]
for
ld
in
links
[
'l1_data'
]]
sdc
=
get_sdc_connection
()
gfs
=
gridfs
.
GridFS
(
sdc
.
sdc_test
,
"gris_l1_data"
)
found
=
gfs
.
find
({
"_id"
:
{
"$in"
:
file_ids
}})
assert
(
len
(
found
))
==
50
def
test_search
(
client
):
"""Test conversion of (supported) Attrs to query string."""
...
...
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