Commit d8c1ecaa authored by Hamza Baqa's avatar Hamza Baqa

Updates in validation report view on GUI

parent 563938f9
......@@ -62,7 +62,7 @@ _test_utils_conf:
python3 conf.py
_test_utils:
cd semtest/test ;python3 test.py
python3 test.py
_u2u_test:
python3 u2u.py
......
version = 1.0
AMQP_URL=amqp://2XU190DG:BM7F9VB8@mq.dev.f-interop.eu:443/1db49a57-fe56-45a5-aafa-d00f86a3744f
AMQP_EXCHANGE=amq.topic
DOCKER_GW = 172.17.42.1
info:
@echo $(info_message)
version:
@echo SemTest v$(version)
env: ## set env vars
@echo "Creating var env "
export AMQP_URL=$(AMQP_URL)
@echo $(AMQP_URL)
export AMQP_EXCHANGE=$(AMQP_EXCHANGE)
help: ## Help dialog.
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//'`); \
for help_line in $${help_lines[@]}; do \
IFS=$$'#' ; \
help_split=($$help_line) ; \
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
printf "%-30s %s\n" $$help_command $$help_info ; \
done
build-tools: ## builds all testing tool docker images (only testing tool)
@echo $(info_message)
@echo "Starting to build docker images.. "
$(MAKE) _docker-build-semtest
sniff-bus: ## Listen and echo all messages in the event bus
@echo "Using AMQP env vars: {url : $(AMQP_URL), exchange : $(AMQP_EXCHANGE)}"
ioppytest-cli connect
stop-all:
@echo "Stop the SemTest cointainer"
docker stop easyglobalmarket-semtest
run-semtest-testing-tool: ## Run SemTest testing tool in docker container
@echo "Using AMQP env vars: {url : $(AMQP_URL), exchange : $(AMQP_EXCHANGE)}"
docker run -p 9093:8080 -d --rm --env AMQP_EXCHANGE=$(AMQP_EXCHANGE) --env AMQP_URL=$(AMQP_URL) --name easyglobalmarket-semtest easyglobalmarket-semtest
docker run -d --rm --env AMQP_EXCHANGE=$(AMQP_EXCHANGE) --env AMQP_URL=$(AMQP_URL) --env DOCKER_GW=$(DOCKER_GW) --name easyglobalmarket-semtest-launcher easyglobalmarket-semtest-launcher
run-tests: ## runs all unittests
@echo "Using AMQP env vars: {url : $(AMQP_URL), exchange : $(AMQP_EXCHANGE)}"
$(MAKE) _test_utils
run-con-test: ## runs all unittests
@echo "Using AMQP env vars: {url : $(AMQP_URL), exchange : $(AMQP_EXCHANGE)}"
$(MAKE) _test_utils_conf
_test_utils_conf:
cd semtest/test ;python3 test_conf.py
_test_utils:
cd semtest/test ;python3 test.py
install-python-dependencies: ## installs all python pip dependencies
@echo 'installing py3 dependencies...'
@python3 -m pip install ioppytest-utils --user
_check-sudo:
@runner=`whoami` ;\
if test $$runner != "root" ;\
then \
echo "(!) You are not root. This command requires 'sudo -E' \n"; \
fi
_docker-build-semtest:
@echo "Starting to build SemTest testing tools.."
# let's build the testing tool image (same for interop and conformance)
docker build --quiet -t easyglobalmarket-semtest$(version) -f semtest/SemTest/Dockerfile .
docker build --quiet -t easyglobalmarket-semtest-launcher$(version) -f semtest/SemTest_launcher/Dockerfile .
# tag all last version images also with a version-less name
docker tag easyglobalmarket-semtest$(version):latest easyglobalmarket-semtest
docker tag easyglobalmarket-semtest-launcher$(version):latest easyglobalmarket-semtest-launcher
info_message = """ \\n\
******************************************************************************************\n\
docker images naming must follow the following conventions: \n\
\n\
resource_type-sub_type-resource_name-version \n\
\n\
resource_type, sub_type and resource_name cannot contain any special character, nor '-' \n\
version format must comply to vx.x \n\
\n\
examples: \n\
\n\
testing_tool-semtest-v$(version) \n\
\n\
******************************************************************************************\n\\n\
"""
......@@ -2,6 +2,8 @@ import os
from utils.ioppytest_cli import ioppytest_cli
import requests
from subprocess import call
from tabulate import tabulate
import ast
import json
......@@ -37,13 +39,52 @@ JSON_to_Send = json.dumps(
)
ioppytest_cli._ui_display_markdown_text("Waiting for validation ............ ")
#send the file for validation
URL_to_send_validation = "http://"+os.environ['DOCKER_GW']+":9093/SemTest/ontology/test"
res = requests.post(URL_to_send_validation, data=JSON_to_Send)
val = ast.literal_eval(res.text)
val1 = json.loads(json.dumps(val))
val_type_1 = val1['results'][0]['type']
val_type_1_val = val1['results'][0]['value']
val_1_obj = []
val_1_obj.append(val_type_1)
if not val_type_1_val: val_type_1_val="Well Done !!"
val_1_obj.append(val_type_1_val)
val_type_2 = val1['results'][1]['type']
val_type_2_val = val1['results'][1]['value']
val_2_obj = []
val_2_obj.append(val_type_2)
if not val_type_2_val: val_type_2_val="Well Done !!"
val_2_obj.append(val_type_2_val)
val_type_3 = val1['results'][2]['type']
val_type_3_val = val1['results'][2]['value']
val_3_obj = []
val_3_obj.append(val_type_3)
if not val_type_3_val: val_type_3_val="Well Done !!"
val_3_obj.append(val_type_3_val)
to_send = []
to_send.append(val_1_obj)
to_send.append(val_2_obj)
to_send.append(val_3_obj)
#print(tabulate(to_send, headers=['Type of Errors', 'Errors']))
os.remove(file_to_validate_path)
#Display result
#call(["ioppytest-cli", "gui_display_message",res.text])
ioppytest_cli.gui_display_message(res.text,"")
ioppytest_cli._ui_display_markdown_text(tabulate(to_send, headers=['Type of Errors', 'Errors'], tablefmt="grid"))
import os
from utils.ioppytest_cli import ioppytest_cli
from tabulate import tabulate
#print(tabulate([["value1", "value2"], ["value3", "value4"]], ["column 1", "column 2"], tablefmt="plain"))
ioppytest_cli._ui_display_markdown_text(tabulate([["value1", "value2"], ["value3", "value4"]], ["column 1", "column 2"], tablefmt="plain"))
from utils-master.ioppytest_cli import ioppytest_cli
import pika
import os
retval = os.getcwd() + "/tmp"
print(retval)
req = ioppytest_cli.MsgUiRequestSessionConfiguration()
ui_reply = ioppytest_cli._amqp_request(req,'dummy_component')
ioppytest_cli.gui_request_file_upload(retval,"please upload file now :D", ui_reply.users[0])
ioppytest_cli.gui_request_file_upload(retval,"please upload file now :D", ui_reply.users[2])
#ui_reply.users
#print(ui_reply.users)
#print(req)
from utils.ioppytest_cli import ioppytest_cli
from tabulate import tabulate
import pika
import requests
import os
......@@ -26,6 +27,8 @@ file_2_to_validate_path = retval + "/user2/" + file_2_to_validate_name
URL_to_send = "http://"+os.environ['DOCKER_GW']+":9093/SemTest/ontology"
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)
......@@ -37,16 +40,20 @@ r_2 = requests.post(URL_to_send, files=file_2)
j_2 = json.loads(r_2.text)
def dico_to_ont_list(my_dico):
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(j_1))
print("User 2 has these ontologies: ",dico_to_ont_list(j_2))
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))
......@@ -67,4 +74,23 @@ def common_onto(a, b):
return to_send
ioppytest_cli.gui_display_message(common_onto(dico_to_ont_list(j_1),dico_to_ont_list(j_2)),"")
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 "+ui_reply.users[0] + " ref ontologies")
val_2_obj.append(dico_to_ont_list_ontoname(j_1))
val_3_obj = []
val_3_obj.append("User "+ui_reply.users[2] + " ref ontologies")
val_3_obj.append(dico_to_ont_list_ontoname(j_2))
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"))
......@@ -230,6 +230,26 @@ def gui_display_message(text_message, user_id):
_publish_message(msg_display)
_echo_input("message display sent to {}".format(msg_display.routing_key))
def _ui_display_markdown_text(text):
"""
Send message to GUI
"""
_echo_input("Executing debug message %s" % sys._getframe().f_code.co_name)
msg = MsgUiDisplayMarkdownText()
_echo_input(text)
if text:
fields = [
{
'type': 'p',
'value': text
}
]
msg.fields = fields
_publish_message(msg)
@cli.command()
def clear():
......@@ -415,7 +435,6 @@ def ignore(message_type):
_echo_error(ke)
@cli.command()
def enter_debug_context():
"""
(REPL only) Provides user with some extra debugging commands
......@@ -585,8 +604,7 @@ def enter_debug_context():
)
_publish_message(msg)
@cli.command()
@click.argument('text')
def _ui_display_markdown_text(text):
"""
Send message to GUI
......
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