Skip to content

Fix mapbox tests #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,7 @@ async def test_errors_are_reported_correctly(self, async_client):
assert "42" == error["index"]["_id"]
assert "i" == error["index"]["_index"]
print(error["index"]["error"])
assert "MapperParsingException" in repr(
error["index"]["error"]
) or "mapper_parsing_exception" in repr(error["index"]["error"])
assert error["index"]["error"]["type"] == "document_parsing_exception"

async def test_error_is_raised(self, async_client):
await async_client.indices.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import pytest
import pytest_asyncio

from elasticsearch_serverless import AsyncElasticsearch, RequestError
from elasticsearch_serverless import RequestError

pytestmark = pytest.mark.asyncio

Expand Down Expand Up @@ -74,9 +74,8 @@ async def mvt_setup(async_client):
)


async def test_mapbox_vector_tile_error(elasticsearch_url, mvt_setup):
client = AsyncElasticsearch(elasticsearch_url)
await client.search_mvt(
async def test_mapbox_vector_tile_error(async_client, mvt_setup):
await async_client.search_mvt(
index="museums",
zoom=13,
x=4207,
Expand All @@ -85,7 +84,7 @@ async def test_mapbox_vector_tile_error(elasticsearch_url, mvt_setup):
)

with pytest.raises(RequestError) as e:
await client.search_mvt(
await async_client.search_mvt(
index="museums",
zoom=-100,
x=4207,
Expand Down Expand Up @@ -114,15 +113,13 @@ async def test_mapbox_vector_tile_error(elasticsearch_url, mvt_setup):
}


async def test_mapbox_vector_tile_response(elasticsearch_url, mvt_setup):
async def test_mapbox_vector_tile_response(async_client, mvt_setup):
try:
import mapbox_vector_tile
except ImportError:
return pytest.skip("Requires the 'mapbox-vector-tile' package")

client = AsyncElasticsearch(elasticsearch_url)

resp = await client.search_mvt(
resp = await async_client.search_mvt(
index="museums",
zoom=13,
x=4207,
Expand Down
4 changes: 1 addition & 3 deletions test_elasticsearch_serverless/test_server/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,7 @@ def test_errors_are_reported_correctly(sync_client):
assert "42" == error["index"]["_id"]
assert "i" == error["index"]["_index"]
print(error["index"]["error"])
assert "MapperParsingException" in repr(
error["index"]["error"]
) or "mapper_parsing_exception" in repr(error["index"]["error"])
assert error["index"]["error"]["type"] == "document_parsing_exception"


def test_error_is_raised(sync_client):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import pytest

from elasticsearch_serverless import Elasticsearch, RequestError
from elasticsearch_serverless import RequestError


@pytest.fixture(scope="function")
Expand Down Expand Up @@ -67,13 +67,12 @@ def mvt_setup(sync_client):
"included": True,
},
],
refresh=True,
)


@pytest.mark.parametrize("node_class", ["urllib3", "requests"])
def test_mapbox_vector_tile_error(elasticsearch_url, mvt_setup, node_class):
client = Elasticsearch(elasticsearch_url, node_class=node_class)
client.search_mvt(
def test_mapbox_vector_tile_error(sync_client, mvt_setup):
sync_client.search_mvt(
index="museums",
zoom=13,
x=4207,
Expand All @@ -82,7 +81,7 @@ def test_mapbox_vector_tile_error(elasticsearch_url, mvt_setup, node_class):
)

with pytest.raises(RequestError) as e:
client.search_mvt(
sync_client.search_mvt(
index="museums",
zoom=-100,
x=4207,
Expand Down Expand Up @@ -111,16 +110,13 @@ def test_mapbox_vector_tile_error(elasticsearch_url, mvt_setup, node_class):
}


@pytest.mark.parametrize("node_class", ["urllib3", "requests"])
def test_mapbox_vector_tile_response(elasticsearch_url, mvt_setup, node_class):
def test_mapbox_vector_tile_response(sync_client, mvt_setup):
try:
import mapbox_vector_tile
except ImportError:
return pytest.skip("Requires the 'mapbox-vector-tile' package")

client = Elasticsearch(elasticsearch_url, node_class=node_class)

resp = client.search_mvt(
resp = sync_client.search_mvt(
index="museums",
zoom=13,
x=4207,
Expand Down
Loading