Commit 3e726486 authored by Hamza Baqa's avatar Hamza Baqa

add prints

parent bd550db6
......@@ -102,5 +102,6 @@ to_send.append(val_1_obj)
to_send.append(val_2_obj)
to_send.append(val_3_obj)
print('report generated \n' + tabulate(to_send, tablefmt="grid") )
ioppytest_cli._ui_display_markdown_text(tabulate(to_send, tablefmt="grid"))
print('report sent')
from utils.ioppytest_cli import ioppytest_cli
from tabulate import tabulate
import pika
import requests
import os
import json
retval = os.getcwd() + "/tmp"
print(retval)
req = ioppytest_cli.MsgUiRequestSessionConfiguration()
ui_reply = ioppytest_cli._amqp_request(req,'dummy_component')
session_user = ui_reply.users
session_user.remove('myslice')
ioppytest_cli.gui_request_file_upload(retval+"/user1","please upload file now :D", session_user[0])
ioppytest_cli.gui_request_file_upload(retval+"/user2","please upload file now :D", session_user[1])
file_1_to_validate_name = os.listdir(retval+"/user1")
file_1_to_validate_name.remove('test')
file_2_to_validate_name = os.listdir(retval+"/user2")
file_2_to_validate_name.remove('test')
file_1_to_validate_path = retval + "/user1/" + file_1_to_validate_name[0]
file_2_to_validate_path = retval + "/user2/" + file_2_to_validate_name[0]
#URL_to_send = "http://"+os.environ['DOCKER_GW']+":9093/SemTest/ontology"
DOCKER_GW = os.environ['SEMTEST_ONTOLOGY_VALIDATOR_URL']
URL_to_send_validation = DOCKER_GW + "/SemTest/ontology"
print("I will send the file to URL_to_send_validation")
ioppytest_cli._ui_display_markdown_text("Waiting for validation ............ ")
#Upload file 1
file_1 = {'file': open(file_1_to_validate_path, 'rb')}
r_1 = requests.post(URL_to_send, files=file_1)
j_1 = json.loads(r_1.text)
#Upload file 2
file_2 = {'file': open(file_2_to_validate_path, 'rb')}
r_2 = requests.post(URL_to_send, files=file_2)
j_2 = json.loads(r_2.text)
def dico_to_ont_list_ontopath(my_dico):
li = []
for my_ob in my_dico['ref_ontologies']:
li.append(my_ob['OntoPath'])
return li
def dico_to_ont_list_ontoname(my_dico):
li = []
for my_ob in my_dico['ref_ontologies']:
li.append(my_ob['OntoName'])
return li
print("User 1 has these ontologies: ",dico_to_ont_list_ontopath(j_1))
print("User 2 has these ontologies: ",dico_to_ont_list_ontopath(j_2))
def lengths(x):
if isinstance(x,list):
yield len(x)
for y in x:
yield from lengths(y)
def common_onto(a, b):
a_set = set(a)
b_set = set(b)
if (a_set & b_set):
to_send = " Interoperable at: {0} %".format((len(a_set & b_set)/len(min(a,b)))*100)
else:
to_send = "No shared vocabulary"
return to_send
val_1_obj = []
val_1_obj.append("Veridict")
val_1_obj.append(common_onto(dico_to_ont_list_ontopath(j_1),dico_to_ont_list_ontopath(j_2)))
val_2_obj = []
val_2_obj.append("User "+session_user[0] + " ref ontologies")
val_2_obj.append(dico_to_ont_list_ontoname(j_1))
val_3_obj = []
val_3_obj.append("User "+session_user[1] + " ref ontologies")
val_3_obj.append(dico_to_ont_list_ontoname(j_2))
#Remove files
os.remove(file_1_to_validate_path)
os.remove(file_2_to_validate_path)
to_send = []
to_send.append(val_1_obj)
to_send.append(val_2_obj)
to_send.append(val_3_obj)
ioppytest_cli._ui_display_markdown_text(tabulate(to_send, tablefmt="grid"))
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