Commit 9e0f66c2 authored by Ismail Moumni's avatar Ismail Moumni
Browse files

adding test

parent d82b41ee
Pipeline #686 failed with stage
in 12 seconds
......@@ -3,12 +3,11 @@ import socket
import json
import os
import sys
import database as db
# import database as db
sys.path.append(os.path.realpath('../softwares/'))
__RDOS_Dict__ = {"ismail": "moumni"}
__RDOS_Dict__ = {}
# tools List
__RDOS_Tool__ = []
......@@ -37,16 +36,15 @@ class RdosServer:
dt_js = json.dumps(send_param_client(__RDOS_Dict__, Tool))
print(dt_js)
conn.send(bytes((dt_js), "utf-8"))
conn.close()
# Function query_valid matches the query send from client side
# Function query_valwid matches the query send from client side
# with the the parameter dict
# Function input dictionnary from client
# Function output boolean true if match else False
def query_valid(data: dict):
if 'parameters' in data:
if (data['parameters'] == 'request') & (len(data) <= 2):
if (data['parameters'] != '') & (len(data) <= 2):
return True
return False
......@@ -58,11 +56,8 @@ def query_valid(data: dict):
# Function output returns a new dictionnary containing arguments
# # for db query and list of tools
def send_param_client(__RDOS_Dict__: dict, __RDOS_Tools__: list):
dict_cl = {}
if len(__RDOS_Dict__) > 0:
dict_cl["tool"] = (__RDOS_Tools__)
s = {**__RDOS_Dict__, **dict_cl}
return s
# req = db.getParameters()
pass
# Function json_loads changes a json file into a Dict
......@@ -76,8 +71,9 @@ def json_to_dict(js):
# Function takes a dictionnary for input
# Function return a Dict containing tool parameters and default parameters
def db_req(tool: dict):
tool_dict = db.getParameters(tool)
return tool_dict
# tool_dict = db.getParameters(tool)
# return tool_dict
pass
def match_query_dict(biblio: dict, data: dict):
......@@ -101,7 +97,7 @@ def match_generator_dict(biblio: dict, Genereator: list):
def verif_param(data: dict):
# Tuple
tool = data.keys().strip('[]')
s = db.getParameters(data['tool'])
# s = db.getParameters(data['tool'])
parameter = {}
query = {}
if s is not None:
......@@ -123,7 +119,7 @@ def verif_param(data: dict):
if __name__ == '__main__':
tool = 'Regal'
sa = ({'Regal': {'size': '', 'asize': '', 'outputf': '', 'number': '', 'comp': '', 'min': '', 'con': ''}}, {'size': '10', 'asize': '2', 'outputf': '', 'number': '1', 'comp': 'yes', 'min': '', 'con': ''})
# sa = ({'Regal': {'size': '', 'asize': '', 'outputf': '', 'number': '', 'comp': '', 'min': '', 'con': ''}}, {'size': '10', 'asize': '2', 'outputf': '', 'number': '1', 'comp': 'yes', 'min': '', 'con': ''})
# print(verif_param(d, data))
s = {'Regal': {'size': 'qsd', 'asize': '', 'outputf': 'qsd', 'number': 'ss', 'comp': 'qsd', 'min': 'sqsd', 'con': 'qsd'}}
# print(s.get('Regal'))
......
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