# Path: pytablewriter/sanitizer/_elasticsearch.py
# class ElasticsearchIndexNameSanitizer(VarNameSanitizer):
# 
#     __RE_INVALID_INDEX_NAME = re.compile("[" + re.escape('\\/*?"<>|,"') + r"\s]+")
#     __RE_INVALID_INDEX_NAME_HEAD = re.compile("^[_]+")
# 
#     @property
#     def reserved_keywords(self) -> List:
#         return []
# 
#     @property
#     def _invalid_var_name_head_re(self) -> Pattern:
#         return self.__RE_INVALID_INDEX_NAME_HEAD
# 
#     @property
#     def _invalid_var_name_re(self) -> Pattern:
#         return self.__RE_INVALID_INDEX_NAME


import itertools
import pytest
from pytablewriter.sanitizer import ElasticsearchIndexNameSanitizer
    )
    def test_normal(self, value, replace_text, expected):
        sanitized_name = ElasticsearchIndexNameSanitizer(value).sanitize(replace_text)

        assert sanitized_name == expected

        ElasticsearchIndexNameSanitizer(sanitized_name).validate()

    @pytest.mark.parametrize(
        ["value", "replace_text", "expected"],
        [[invalid_char + "hoge_123", "_", "hoge_123"] for invalid_char in "_"]
        + [[invalid_char + "hoge_123", "a", "ahoge_123"] for invalid_char in "_"],
    )
    def test_normal_invalid_first_char_x1(self, value, replace_text, expected):
        sanitized_name = ElasticsearchIndexNameSanitizer(value).sanitize(replace_text)

        assert sanitized_name == expected

        ElasticsearchIndexNameSanitizer(sanitized_name).validate()

    @pytest.mark.parametrize(
        ["value", "replace_text", "expected"],
        [[invalid_char * 2 + "hoge_123", "_", "hoge_123"] for invalid_char in "_"]
        + [[invalid_char * 2 + "hoge_123", "a", "aahoge_123"] for invalid_char in "_"],
    )
    def test_normal_invalid_first_char_x2(self, value, replace_text, expected):
        sanitized_name = ElasticsearchIndexNameSanitizer(value).sanitize(replace_text)

        assert sanitized_name == expected


# Path: pytablewriter/sanitizer/_elasticsearch.py
# class ElasticsearchIndexNameSanitizer(VarNameSanitizer):
# 
#     __RE_INVALID_INDEX_NAME = re.compile("[" + re.escape('\\/*?"<>|,"') + r"\s]+")
#     __RE_INVALID_INDEX_NAME_HEAD = re.compile("^[_]+")
# 
#     @property
#     def reserved_keywords(self) -> List:
#         return []
# 
#     @property
#     def _invalid_var_name_head_re(self) -> Pattern:
#         return self.__RE_INVALID_INDEX_NAME_HEAD
# 
#     @property
#     def _invalid_var_name_re(self) -> Pattern:
#         return self.__RE_INVALID_INDEX_NAME


# Path: test/sanitizer/test_elasticsearch.py
import itertools
import pytest
from pytablewriter.sanitizer import ElasticsearchIndexNameSanitizer

    )
    def test_normal(self, value, replace_text, expected):
        sanitized_name = ElasticsearchIndexNameSanitizer(value).sanitize(replace_text)

        assert sanitized_name == expected

        ElasticsearchIndexNameSanitizer(sanitized_name).validate()

    @pytest.mark.parametrize(
        ["value", "replace_text", "expected"],
        [[invalid_char + "hoge_123", "_", "hoge_123"] for invalid_char in "_"]
        + [[invalid_char + "hoge_123", "a", "ahoge_123"] for invalid_char in "_"],
    )
    def test_normal_invalid_first_char_x1(self, value, replace_text, expected):
        sanitized_name = ElasticsearchIndexNameSanitizer(value).sanitize(replace_text)

        assert sanitized_name == expected

        ElasticsearchIndexNameSanitizer(sanitized_name).validate()

    @pytest.mark.parametrize(
        ["value", "replace_text", "expected"],
        [[invalid_char * 2 + "hoge_123", "_", "hoge_123"] for invalid_char in "_"]
        + [[invalid_char * 2 + "hoge_123", "a", "aahoge_123"] for invalid_char in "_"],
    )
    def test_normal_invalid_first_char_x2(self, value, replace_text, expected):
        sanitized_name = ElasticsearchIndexNameSanitizer(value).sanitize(replace_text)

        assert sanitized_name == expected


        ElasticsearchIndexNameSanitizer(sanitized_name).validate()