コード例 #1
0
ファイル: test_data_models.py プロジェクト: onicagroup/runway
 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
     )
コード例 #2
0
ファイル: test_data_models.py プロジェクト: onicagroup/runway
 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
     )
コード例 #3
0
ファイル: test_data_models.py プロジェクト: onicagroup/runway
 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)
コード例 #4
0
ファイル: test_data_models.py プロジェクト: onicagroup/runway
 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)
コード例 #5
0
ファイル: test_data_models.py プロジェクト: onicagroup/runway
 def test_validate_str_type_error(self, provided: Any) -> None:
     """Test _validate_str raise TypeError."""
     with pytest.raises(TypeError):
         BaseModel._validate_str(provided)
コード例 #6
0
ファイル: test_data_models.py プロジェクト: onicagroup/runway
 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)
コード例 #7
0
ファイル: test_data_models.py プロジェクト: onicagroup/runway
 def test_validate_path_type_error(self) -> None:
     """Test _validate_path raise TypeError."""
     with pytest.raises(TypeError):
         BaseModel._validate_path(13)
コード例 #8
0
ファイル: test_data_models.py プロジェクト: onicagroup/runway
 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
コード例 #9
0
ファイル: test_data_models.py プロジェクト: onicagroup/runway
 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)
コード例 #10
0
ファイル: test_data_models.py プロジェクト: onicagroup/runway
 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")
コード例 #11
0
ファイル: test_data_models.py プロジェクト: onicagroup/runway
 def test_validate_bool(self, provided: Any, expected: bool) -> None:
     """Test _validate_bool."""
     assert BaseModel._validate_bool(provided) is expected