Ejemplo n.º 1
0
 def test_validate_dict(
     self,
     provided: Any,
     optional: bool,
     required: bool,
     expected: Optional[Dict[str, Any]],
 ) -> None:
     """Test _validate_dict."""
     assert (
         BaseModel._validate_dict(provided, optional=optional, required=required)
         == expected
     )
Ejemplo n.º 2
0
 def test_validate_dict_value_error(self) -> None:
     """Test _validate_dict raise ValueError."""
     with pytest.raises(ValueError):
         BaseModel._validate_dict(["something"])  # type: ignore
     with pytest.raises(ValueError):
         BaseModel._validate_dict(None, required=True)
     with pytest.raises(ValueError):
         BaseModel._validate_dict({}, required=True)