def test_validate_str( self, provided: Any, optional: bool, required: bool, expected: Optional[str] ) -> None: """Test _validate_str.""" assert ( BaseModel._validate_str(provided, optional=optional, required=required) == expected )
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 )
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)
def test_validate_str_value_error(self) -> None: """Test _validate_str raise ValueError.""" with pytest.raises(ValueError): BaseModel._validate_str(None, required=True) with pytest.raises(ValueError): BaseModel._validate_str("", required=True)
def test_validate_str_type_error(self, provided: Any) -> None: """Test _validate_str raise TypeError.""" with pytest.raises(TypeError): BaseModel._validate_str(provided)
def test_validate_path_value_error(self, tmp_path: Path) -> None: """Test _validate_path raise ValueError.""" with pytest.raises(ValueError): BaseModel._validate_path(tmp_path / "missing", must_exist=True)
def test_validate_path_type_error(self) -> None: """Test _validate_path raise TypeError.""" with pytest.raises(TypeError): BaseModel._validate_path(13)
def test_validate_path(self, tmp_path: Path) -> None: """Test validate_path.""" assert BaseModel._validate_path(str(tmp_path)) == tmp_path assert BaseModel._validate_path(str(tmp_path), must_exist=True) == tmp_path assert BaseModel._validate_path(tmp_path) == tmp_path assert BaseModel._validate_path(tmp_path, must_exist=True) == tmp_path
def test_validate_list_str_type_error(self) -> None: """Test _validate_list_str raise TypeError.""" with pytest.raises(TypeError): BaseModel._validate_list_str(["something", None]) with pytest.raises(TypeError): BaseModel._validate_list_str(1)
def test_validate_int_value_error(self) -> None: """Test _validate_int raise ValueError.""" with pytest.raises(ValueError): BaseModel._validate_int(None, required=True) with pytest.raises(ValueError): BaseModel._validate_int("something")
def test_validate_bool(self, provided: Any, expected: bool) -> None: """Test _validate_bool.""" assert BaseModel._validate_bool(provided) is expected