File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -233,3 +233,20 @@ def test_optionally_keyed_by():
233233
234234 with pytest .raises (MultipleInvalid ):
235235 validator ({"by-bar" : {"a" : "b" }})
236+
237+
238+ def test_optionally_keyed_by_mulitple_keys ():
239+ validator = optionally_keyed_by ("foo" , "bar" , str )
240+ assert validator ("baz" ) == "baz"
241+ assert validator ({"by-foo" : {"a" : "b" , "c" : "d" }}) == {"a" : "b" , "c" : "d" }
242+ assert validator ({"by-bar" : {"x" : "y" }}) == {"x" : "y" }
243+ assert validator ({"by-foo" : {"a" : {"by-bar" : {"x" : "y" }}}}) == {"a" : {"x" : "y" }}
244+
245+ with pytest .raises (Invalid ):
246+ validator ({"by-foo" : {"a" : 123 , "c" : "d" }})
247+
248+ with pytest .raises (MultipleInvalid ):
249+ validator ({"by-bar" : {"a" : 1 }})
250+
251+ with pytest .raises (MultipleInvalid ):
252+ validator ({"by-unknown" : {"a" : "b" }})
You can’t perform that action at this time.
0 commit comments