# Path: pytablereader/_constant.py
# class SourceType:
#     TEXT = "text"
#     FILE = "file"
#     URL = "url"
#     OBJECT = "object"
# 
# Path: pytablereader/_validator.py
# class FileValidator(BaseValidator):
#     """
#     Validator class for file data source.
#     """
# 
#     @property
#     def source_type(self):
#         return SourceType.FILE
# 
#     def validate(self):
#         try:
#             pv.validate_filepath(self.source, platform="auto")
#         except pv.ValidationError as e:
#             raise InvalidFilePathError(e)
# 
#         if os.path.isfile(self.source) or is_fifo(self.source):
#             return
# 
#         raise OSError("file not found")
# 
# class TextValidator(BaseValidator):
#     """
#     Validator class for text object data source.
#     """
# 
#     @property
#     def source_type(self):
#         return SourceType.TEXT
# 
#     def validate(self):
#         if typepy.is_null_string(self.source):
#             raise DataError("data source is empty")
# 
# class UrlValidator(BaseValidator):
#     """
#     Validator class for URL data source.
#     """
# 
#     @property
#     def source_type(self):
#         return SourceType.URL
# 
#     def validate(self):
#         if typepy.is_null_string(self.source):
#             raise UrlError("url is empty")
# 
#         scheme = urlparse(self.source).scheme
#         if scheme not in ["http", "https"]:
#             raise UrlError(f"invalid scheme: expected=http/https, actual={scheme}")
# 
# def is_fifo(file_path: str) -> bool:
#     try:
#         return stat.S_ISFIFO(os.stat(file_path).st_mode)
#     except OSError as e:
#         logger.error(f"errno: {e.errno}")
# 
#         if e.errno not in (EBADF, ENAMETOOLONG, ENOENT, ENOTDIR):
#             raise
# 
#         return False
#     except ValueError:
#         return False


import platform
import pytest
import pytablereader as ptr
from pytablereader._constant import SourceType
from pytablereader._validator import FileValidator, TextValidator, UrlValidator, is_fifo
            validator.validate()


class Test_TextValidator_validate:
    @pytest.mark.parametrize(["value"], [["test"]])
    def test_normal(self, value):
        validator = TextValidator(value)
        assert validator.source_type == SourceType.TEXT
        validator.validate()

    @pytest.mark.parametrize(["value", "expected"], [[None, ptr.DataError], ["", ptr.DataError]])
    def test_exception(self, value, expected):
        validator = TextValidator(value)

        with pytest.raises(expected):
            validator.validate()


class Test_UrlValidator_validate:
    @pytest.mark.parametrize(["value"], [["http://www.google.com"], ["https://github.com/"]])
    def test_normal(self, value):
        validator = UrlValidator(value)
        assert validator.source_type == SourceType.URL
        validator.validate()

    @pytest.mark.parametrize(
        ["value", "expected"],
        [[None, ptr.UrlError], ["", ptr.UrlError], ["www.google.com", ptr.UrlError]],
    )
    def test_exception(self, value, expected):

# Path: pytablereader/_constant.py
# class SourceType:
#     TEXT = "text"
#     FILE = "file"
#     URL = "url"
#     OBJECT = "object"
# 
# Path: pytablereader/_validator.py
# class FileValidator(BaseValidator):
#     """
#     Validator class for file data source.
#     """
# 
#     @property
#     def source_type(self):
#         return SourceType.FILE
# 
#     def validate(self):
#         try:
#             pv.validate_filepath(self.source, platform="auto")
#         except pv.ValidationError as e:
#             raise InvalidFilePathError(e)
# 
#         if os.path.isfile(self.source) or is_fifo(self.source):
#             return
# 
#         raise OSError("file not found")
# 
# class TextValidator(BaseValidator):
#     """
#     Validator class for text object data source.
#     """
# 
#     @property
#     def source_type(self):
#         return SourceType.TEXT
# 
#     def validate(self):
#         if typepy.is_null_string(self.source):
#             raise DataError("data source is empty")
# 
# class UrlValidator(BaseValidator):
#     """
#     Validator class for URL data source.
#     """
# 
#     @property
#     def source_type(self):
#         return SourceType.URL
# 
#     def validate(self):
#         if typepy.is_null_string(self.source):
#             raise UrlError("url is empty")
# 
#         scheme = urlparse(self.source).scheme
#         if scheme not in ["http", "https"]:
#             raise UrlError(f"invalid scheme: expected=http/https, actual={scheme}")
# 
# def is_fifo(file_path: str) -> bool:
#     try:
#         return stat.S_ISFIFO(os.stat(file_path).st_mode)
#     except OSError as e:
#         logger.error(f"errno: {e.errno}")
# 
#         if e.errno not in (EBADF, ENAMETOOLONG, ENOENT, ENOTDIR):
#             raise
# 
#         return False
#     except ValueError:
#         return False


# Path: test/test_validator.py
import platform
import pytest
import pytablereader as ptr
from pytablereader._constant import SourceType
from pytablereader._validator import FileValidator, TextValidator, UrlValidator, is_fifo

            validator.validate()


class Test_TextValidator_validate:
    @pytest.mark.parametrize(["value"], [["test"]])
    def test_normal(self, value):
        validator = TextValidator(value)
        assert validator.source_type == SourceType.TEXT
        validator.validate()

    @pytest.mark.parametrize(["value", "expected"], [[None, ptr.DataError], ["", ptr.DataError]])
    def test_exception(self, value, expected):
        validator = TextValidator(value)

        with pytest.raises(expected):
            validator.validate()


class Test_UrlValidator_validate:
    @pytest.mark.parametrize(["value"], [["http://www.google.com"], ["https://github.com/"]])
    def test_normal(self, value):
        validator = UrlValidator(value)
        assert validator.source_type == SourceType.URL
        validator.validate()

    @pytest.mark.parametrize(
        ["value", "expected"],
        [[None, ptr.UrlError], ["", ptr.UrlError], ["www.google.com", ptr.UrlError]],
    )
    def test_exception(self, value, expected):

        validator = UrlValidator(value)