File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -311,7 +311,9 @@ def test_get_ntp_peers(self, test_case):
311311
312312 for peer , peer_details in get_ntp_peers .items ():
313313 assert isinstance (peer , str )
314- assert helpers .test_model (models .NTPPeerDict , peer_details )
314+ assert helpers .test_model (
315+ models .NTPPeerDict , peer_details , allow_subset = True
316+ )
315317
316318 return get_ntp_peers
317319
@@ -323,7 +325,9 @@ def test_get_ntp_servers(self, test_case):
323325
324326 for server , server_details in get_ntp_servers .items ():
325327 assert isinstance (server , str )
326- assert helpers .test_model (models .NTPServerDict , server_details )
328+ assert helpers .test_model (
329+ models .NTPServerDict , server_details , allow_subset = True
330+ )
327331
328332 return get_ntp_servers
329333
Original file line number Diff line number Diff line change 11"""Several methods to help with the tests."""
22
33
4- def test_model (model , data ):
4+ def test_model (model , data , allow_subset = False ):
55 """Return if the dictionary `data` complies with the `model`."""
66 # Access the underlying schema for a TypedDict directly
77 annotations = model .__annotations__
8- if model .__total__ :
9- same_keys = set (annotations .keys ()) == set (data .keys ())
10- else :
8+ if allow_subset :
119 same_keys = set (data .keys ()) <= set (annotations .keys ())
10+ source = data
11+ else :
12+ same_keys = set (annotations .keys ()) == set (data .keys ())
13+ source = annotations
1214
1315 if not same_keys :
1416 print (
@@ -18,7 +20,7 @@ def test_model(model, data):
1820 )
1921
2022 correct_class = True
21- for key in data .keys ():
23+ for key in source .keys ():
2224 correct_class = isinstance (data [key ], annotations [key ]) and correct_class
2325 if not correct_class :
2426 print (
You can’t perform that action at this time.
0 commit comments