EOX GitLab Instance
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ESA
PRISM
VS
Commits
e2b06f27
Commit
e2b06f27
authored
4 years ago
by
Mussab Abdalla
Browse files
Options
Downloads
Patches
Plain Diff
adding tests for sftp reports
parent
f8ed9ec1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
testing/registrar_test.py
+41
-0
41 additions, 0 deletions
testing/registrar_test.py
testing/registrar_test.sh
+0
-19
0 additions, 19 deletions
testing/registrar_test.sh
testing/requirements.txt
+1
-0
1 addition, 0 deletions
testing/requirements.txt
with
42 additions
and
19 deletions
testing/registrar_test.py
+
41
−
0
View file @
e2b06f27
...
...
@@ -3,7 +3,9 @@ import csv
import
pytest
import
psycopg2
import
paramiko
from
dotenv
import
load_dotenv
from
xml.etree
import
ElementTree
@pytest.fixture
(
scope
=
"
session
"
)
...
...
@@ -28,6 +30,14 @@ def identifiers():
yield
csv
.
reader
(
f
)
@pytest.fixture
def
sftp_connection
():
transport
=
paramiko
.
Transport
((
'
localhost
'
,
2222
))
transport
.
connect
(
username
=
'
eox
'
,
password
=
'
password
'
)
with
paramiko
.
SFTPClient
.
from_transport
(
transport
)
as
sftp
:
yield
sftp
def
query_eo_object
(
connection
,
eo_id
):
query
=
f
"
SELECT identifier FROM coverages_eoobject WHERE identifier =
'
{
eo_id
}
'
;
"
with
connection
.
cursor
()
as
cursor
:
...
...
@@ -39,3 +49,34 @@ def test_db_name(connection, identifiers):
for
row
in
identifiers
:
identifier
=
row
[
0
].
split
(
'
/
'
)[
4
]
query_eo_object
(
connection
,
identifier
)
def
compare_links
(
sftp
,
product_xml
,
product
):
report
=
sftp
.
file
(
"
data/to/panda/%s
"
%
product_xml
)
xml_file
=
report
.
read
()
root
=
ElementTree
.
fromstring
(
xml_file
.
decode
(
'
utf-8
'
))
urls
=
root
.
findall
(
'
{http://www.telespazio.com/CSCDA/CDD/PDAS}URL
'
)
wms_link
=
urls
[
0
].
find
(
'
{http://www.telespazio.com/CSCDA/CDD/PDAS}URL
'
).
text
wcs_link
=
urls
[
1
].
find
(
'
{http://www.telespazio.com/CSCDA/CDD/PDAS}URL
'
).
text
wms_capabilities
=
'
emg.pass.copernicus.eu/ows?service=wms&request=GetCapabilities&&cql=identifier=
'
wcs_capabilities
=
'
emg.pass.copernicus.eu/ows?service=wcs&request=GetCapabilities&&cql=identifier=
'
expected_wms_link
=
'
%s
"
%s
"'
%
(
wms_capabilities
,
product
)
expected_wcs_link
=
'
%s
"
%s
"'
%
(
wcs_capabilities
,
product
)
assert
expected_wms_link
.
replace
(
'
&&
'
,
'
&
'
)
==
wms_link
assert
expected_wcs_link
.
replace
(
'
&&
'
,
'
&
'
)
==
wcs_link
def
test_reporting
(
sftp_connection
,
identifiers
):
report_list
=
sftp_connection
.
listdir
(
'
data/to/panda/
'
)
assert
len
(
report_list
)
>
0
for
item
in
report_list
:
for
row
in
identifiers
:
identifier
=
row
[
0
].
split
(
'
/
'
)[
4
]
if
identifier
in
item
:
compare_links
(
sftp_connection
,
item
,
identifier
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
testing/registrar_test.sh
+
0
−
19
View file @
e2b06f27
...
...
@@ -11,25 +11,6 @@ while read product; do
--reporting-dir
"/mnt/reports"
\
<<<
$product
IFS
=
'/'
read
-ra
ADDR
<<<
"
$product
"
docker
exec
$(
docker ps
-qf
"name=emg-pvs_registrar"
)
bash
-c
'ls /mnt/reports/. | grep $ADDR[4]'
>>
${
ADDR
[4]
}
.csv
while
IFS
=
""
read
-r
name
do
docker
exec
$(
docker ps
-qf
"name=emg-pvs_registrar"
)
cat
/mnt/reports/
$name
>
temp.xml
tail
-n
+2 temp.xml
>
${
ADDR
[4]
}
.xml
done
<
${
ADDR
[4]
}
.csv
rm
${
ADDR
[4]
}
.csv temp.xml
done
<
"
$product_list_file
"
pytest
#-s registrar_test.py --name $product_list_file
# Remove the created xml reports
while
read
product
;
do
IFS
=
'/'
read
-ra
ADDR
<<<
"
$product
"
rm
${
ADDR
[4]
}
.xml
done
<
$product_list_file
This diff is collapsed.
Click to expand it.
testing/requirements.txt
+
1
−
0
View file @
e2b06f27
pytest
psycopg2
python-dotenv
paramiko
# python-swiftclient
# python-keystoneclient
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment