From 35d6d9995ed9ed32e9b676e9e3deae29bef756c6 Mon Sep 17 00:00:00 2001 From: baloola <baloola-mu@hotmail.com> Date: Wed, 30 Sep 2020 13:53:41 +0200 Subject: [PATCH] complete initial report testing --- registrar_test.py | 17 +++++++++++++++++ registrar_test.sh | 15 ++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/registrar_test.py b/registrar_test.py index 7d2df633..66249e81 100644 --- a/registrar_test.py +++ b/registrar_test.py @@ -1,6 +1,7 @@ import psycopg2 import os import csv +from xml.etree import ElementTree with open('./env/emg_db.env', 'r') as f: @@ -42,6 +43,22 @@ def test_db_name(name): spamreader = csv.reader(csvfile) for row in spamreader: identifier = row[0].split('/')[4] + + xml_file= "%s.xml"% identifier + tree = ElementTree.parse(xml_file) + root = tree.getroot() + 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, identifier) + expected_wcs_link = '%s"%s"' % (wcs_capabilities, identifier) + assert expected_wms_link.replace('&&', '&') == wms_link + assert expected_wcs_link.replace('&&', '&') == wcs_link + connect_to_db(identifier) assert coverage_id == identifier assert db_name == database diff --git a/registrar_test.sh b/registrar_test.sh index a3009530..84f50c67 100755 --- a/registrar_test.sh +++ b/registrar_test.sh @@ -2,7 +2,7 @@ product_list_file=$1 docker exec -i $(docker ps -qf "name=emg-pvs_registrar") python3 /var/www/pvs/dev/pvs_instance/manage.py storage create pvs_testing pvs_testing --type swift --storage-auth auth-cloud-ovh IFS="," -# For testing the service url and the reporting directory canbe fixed and not mapped from env +# For testing purposses 'service url' and 'reporting directory' values can be fixed and not mapped from env SERVICE_URL=emg.pass.copernicus.eu REPORTING_DIR=/mnt/reports/ while read product; do @@ -15,14 +15,19 @@ echo "docker exec -i $(docker ps -qf "name=emg-pvs_registrar") python3 /core/reg while IFS="" read -r name do - - docker exec $(docker ps -qf "name=emg-pvs_registrar") cat /mnt/reports/$name >> ${ADDR[4]}.xml - + 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 + 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 -- GitLab