test_query_valid.py 558 Bytes
Newer Older
Ismail Moumni's avatar
Ismail Moumni committed
1
2
3
4
5
6
#!/usr/bin/ python3
# Authors : Julien DAVID & Ismail MOUMNI
import sys
import os
import pytest
import json
Ismail Moumni's avatar
edit    
Ismail Moumni committed
7
sys.path.append(os.path.realpath('../softwares/'))
Ismail Moumni's avatar
edit    
Ismail Moumni committed
8

Ismail Moumni's avatar
edit    
Ismail Moumni committed
9
import server.server as serv # noqa E402
Ismail Moumni's avatar
Ismail Moumni committed
10
11


Ismail Moumni's avatar
edit    
Ismail Moumni committed
12
13
data_test1 = '{"parameters": "request"}'
data_test2 = '{"Ref": "Parameters"}'
Ismail Moumni's avatar
Ismail Moumni committed
14
15


Ismail Moumni's avatar
tests    
Ismail Moumni committed
16
data_load = json.loads((data_test1))
Ismail Moumni's avatar
Ismail Moumni committed
17
18
19
20
21
data_load2 = json.loads(data_test2)


def test_query_valid(data: dict):
    var = serv.query_valid(data_load)
Ismail Moumni's avatar
Ismail Moumni committed
22
    assert var is True
Ismail Moumni's avatar
Ismail Moumni committed
23
24
25
26
27


def test_bad_missing():
    with pytest.raises(Exception):
        assert serv.query_valid(data_load2)