Skip to content

Use client fixtures for mapbox tests #2579

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
Jun 6, 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
6 changes: 1 addition & 5 deletions test_elasticsearch/test_async/test_server/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,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 error["index"]["error"]["type"] in [
"mapper_parsing_exception",
# Elasticsearch 8.8+: https://github.com/elastic/elasticsearch/pull/92646
"document_parsing_exception",
]
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 import AsyncElasticsearch, RequestError
from elasticsearch 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, ca_certs):
client = AsyncElasticsearch(elasticsearch_url, ca_certs=ca_certs)
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, ca_certs):
)

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, ca_certs):
}


async def test_mapbox_vector_tile_response(elasticsearch_url, mvt_setup, ca_certs):
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, ca_certs=ca_certs)

resp = await client.search_mvt(
resp = await async_client.search_mvt(
index="museums",
zoom=13,
x=4207,
Expand Down
6 changes: 1 addition & 5 deletions test_elasticsearch/test_server/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,7 @@ def test_errors_are_reported_correctly(sync_client):
assert "42" == error["index"]["_id"]
assert "i" == error["index"]["_index"]
print(error["index"]["error"])
assert error["index"]["error"]["type"] in [
"mapper_parsing_exception",
# Elasticsearch 8.8+: https://github.com/elastic/elasticsearch/pull/92646
"document_parsing_exception",
]
assert error["index"]["error"]["type"] == "document_parsing_exception"


def test_error_is_raised(sync_client):
Expand Down
20 changes: 5 additions & 15 deletions test_elasticsearch/test_server/test_mapbox_vector_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

from elasticsearch import RequestError

from .conftest import _create


@pytest.fixture(scope="function")
def mvt_setup(sync_client):
Expand Down Expand Up @@ -73,11 +71,8 @@ def mvt_setup(sync_client):
)


@pytest.mark.parametrize("node_class", ["urllib3", "requests"])
def test_mapbox_vector_tile_error(elasticsearch_url, mvt_setup, node_class, ca_certs):
client = _create(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 @@ -86,7 +81,7 @@ def test_mapbox_vector_tile_error(elasticsearch_url, mvt_setup, node_class, ca_c
)

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


@pytest.mark.parametrize("node_class", ["urllib3", "requests"])
def test_mapbox_vector_tile_response(
elasticsearch_url, mvt_setup, node_class, ca_certs
):
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 = _create(elasticsearch_url, node_class=node_class)

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