Skip to content

Commit

Permalink
Added a test that makes sure the slash is properly encoded.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Nov 27, 2024
1 parent 0716eda commit fb4dc05
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test_opensearchpy/test_async/test_server/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,22 @@
import pytest
from _pytest.mark.structures import MarkDecorator

from opensearchpy.exceptions import RequestError

pytestmark: MarkDecorator = pytest.mark.asyncio


class TestSpecialCharacters:
async def test_index_with_slash(self, async_client: Any) -> None:
index_name = "movies/shmovies"
with pytest.raises(RequestError) as e:
await async_client.indices.create(index=index_name)
assert (
str(e.value)
== "RequestError(400, 'invalid_index_name_exception', 'Invalid index name [movies/shmovies], must not contain the following characters [ , \", *, \\\\, <, |, ,, >, /, ?]')"
)


class TestUnicode:
async def test_indices_lifecycle_english(self, async_client: Any) -> None:
index_name = "movies"
Expand Down
15 changes: 15 additions & 0 deletions test_opensearchpy/test_server/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,24 @@
# under the License.


import pytest

from opensearchpy.exceptions import RequestError

from . import OpenSearchTestCase


class TestSpecialCharacters(OpenSearchTestCase):
def test_index_with_slash(self) -> None:
index_name = "movies/shmovies"
with pytest.raises(RequestError) as e:
self.client.indices.create(index=index_name)
self.assertEqual(
str(e.value),
"RequestError(400, 'invalid_index_name_exception', 'Invalid index name [movies/shmovies], must not contain the following characters [ , \", *, \\\\, <, |, ,, >, /, ?]')"
)


class TestUnicode(OpenSearchTestCase):
def test_indices_lifecycle_english(self) -> None:
index_name = "movies"
Expand Down

0 comments on commit fb4dc05

Please sign in to comment.