Skip to content
Snippets Groups Projects
Commit d453f04f authored by Ismail Moumni's avatar Ismail Moumni
Browse files

Adding EXCEPTION

parent 9cd68b2c
No related branches found
No related tags found
1 merge request!5Wip adding tests and json functions
Pipeline #663 passed with stage
in 13 seconds
......@@ -46,13 +46,13 @@ def run_client(Host, Port, message: str):
# Function returns a list containing missing values
def match_dict(biblio: dict, gen: dict):
missing = []
if (len(biblio) != 0):
if(biblio is not None):
for key in biblio:
if key not in gen:
missing.append(key)
return missing
else:
raise TypeError("Dictionnaire Vide!!")
raise Exception("Dictionnaire Vide!!")
# Function send_st sends to socket data bytes
......@@ -129,7 +129,3 @@ def help():
print('Generator parameters :')
for a in __RDOS_Gen__:
print("Parameter: {}, Value : {}".format(a, __RDOS_Gen__[a]))
if __name__ == '__main__':
print(match_query_dict({"lala": "MomO"}, {"lala": "tata"}))
import pytest
import requests
# import requests
def test_stupid():
assert True != False
with pytest.raises(Exception):
assert 'True' == 'False'
......@@ -3,8 +3,8 @@
import client as c
import pytest
test_dict1 = {"name": "Michael"}
test_dict2 = {"name": "Michael"}
test_dict1 = {"name": "Michael", "Rafael": "Nadal"}
test_dict2 = {"name": "Michael", "Rafael": ""}
def test_match():
......@@ -14,4 +14,4 @@ def test_match():
def test_bad_match_dict():
with pytest.raises(Exception):
assert c.match_dict(test_dict1, {})
assert c.match_dict({}, test_dict1)
......@@ -4,8 +4,11 @@ import json
import client as c
import pytest
data = '{"country": "usa", "people": ""}'
bad_data = '{"sasd": "", "nam": {"saasd": "llam"} }'
obj = json.loads(data)
obj2 = json.loads(bad_data)
def test_match_dict():
......@@ -13,6 +16,11 @@ def test_match_dict():
assert var == []
def test_diff_match_dict():
result = c.match_dict(obj, obj2)
assert result is not None
def test_bad_match_dict():
with pytest.raises(Exception):
assert c.match_dict({}, obj)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment