1
1
import json
2
2
3
3
import requests
4
+ from assertpy import assert_that , soft_assertions
4
5
from cerberus import Validator
5
6
6
7
from config import BASE_URI
7
8
8
9
schema = {
9
10
"fname" : {'type' : 'string' },
10
11
"lname" : {'type' : 'string' },
11
- "person_id" : {'type' : 'integer ' },
12
+ "person_id" : {'type' : 'number ' },
12
13
"timestamp" : {'type' : 'string' }
13
14
}
14
15
@@ -17,21 +18,19 @@ def test_read_one_operation_has_expected_schema():
17
18
response = requests .get (f'{ BASE_URI } /1' )
18
19
person = json .loads (response .text )
19
20
20
- validator = Validator (schema )
21
+ validator = Validator (schema , require_all = True )
21
22
is_valid = validator .validate (person )
22
23
23
- if not is_valid :
24
- print (validator .errors )
24
+ assert_that (is_valid , description = validator .errors ).is_true ()
25
25
26
26
27
27
def test_read_all_operation_has_expected_schema ():
28
28
response = requests .get (BASE_URI )
29
29
persons = json .loads (response .text )
30
30
31
- validator = Validator (schema )
31
+ validator = Validator (schema , require_all = True )
32
32
33
- for person in persons :
34
- is_valid = validator .validate (person )
35
-
36
- if not is_valid :
37
- print (validator .errors )
33
+ with soft_assertions ():
34
+ for person in persons :
35
+ is_valid = validator .validate (person )
36
+ assert_that (is_valid , description = validator .errors ).is_true ()
0 commit comments