Compare commits
54 Commits
Author | SHA256 | Date | |
---|---|---|---|
19a34995ac | |||
60ab2816a6 | |||
031b897d5c | |||
e148dbfba4 | |||
82ef2db5fa | |||
7b06cedc8a | |||
63719e803d | |||
54f6b8925f | |||
ca5a4f264b | |||
6ca24de3f1 | |||
2b1cf8849e | |||
368bb519f0 | |||
ca96459bad | |||
1f80f18dae | |||
48f70f4b4b | |||
79f77589b9 | |||
6b71f6fdfb | |||
d2bdec8013 | |||
1c3afb46ac | |||
3dccbfe4cf | |||
320ed84ed5 | |||
0d5b4ecd29 | |||
3bc84cdba5 | |||
ab26cb3ea0 | |||
eccfced67d | |||
a0287c6372 | |||
bb05159f9d | |||
390e993b19 | |||
21057163dd | |||
109d524d87 | |||
6d4f78e463 | |||
|
64a2e1896c | ||
9d724a71df | |||
|
f7ec9f8f8e | ||
982501db3b | |||
b31fa2dc1d | |||
0469c1dcb6 | |||
|
716535bb0e | ||
616500aa0f | |||
|
e8aabf1722 | ||
e193f70bdb | |||
|
b890756a7a | ||
41fb8efd57 | |||
7cbd6a66ee | |||
af98d10667 | |||
f6052996c3 | |||
7b8a4be95a | |||
384275f1a9 | |||
|
6171293b45 | ||
f3e3ca5de8 | |||
|
657977c5ca | ||
|
b861dc1d8b | ||
4a98197b58 | |||
e58008edba |
@@ -1,193 +0,0 @@
|
||||
From 740005db4dcd732015606d86eff29eb15a0193b2 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Garcia Moreno <daniel.garcia@suse.com>
|
||||
Date: Wed, 8 Jan 2025 08:50:23 +0100
|
||||
Subject: [PATCH] Make pyarrow dependency optional for tests
|
||||
|
||||
---
|
||||
.../test_client/test_deprecated_options.py | 40 ++++++++-------
|
||||
.../test_client/test_serializers.py | 49 ++++++++-----------
|
||||
test_elasticsearch/test_serializer.py | 9 +++-
|
||||
3 files changed, 48 insertions(+), 50 deletions(-)
|
||||
|
||||
diff --git a/test_elasticsearch/test_client/test_deprecated_options.py b/test_elasticsearch/test_client/test_deprecated_options.py
|
||||
index 810e75cf..ea797ce8 100644
|
||||
--- a/test_elasticsearch/test_client/test_deprecated_options.py
|
||||
+++ b/test_elasticsearch/test_client/test_deprecated_options.py
|
||||
@@ -22,6 +22,24 @@ import pytest
|
||||
from elasticsearch import Elasticsearch, JsonSerializer
|
||||
|
||||
|
||||
+EXPECTED_SERIALIZERS = {
|
||||
+ "application/vnd.mapbox-vector-tile",
|
||||
+ "application/x-ndjson",
|
||||
+ "application/json",
|
||||
+ "text/*",
|
||||
+ "application/vnd.elasticsearch+json",
|
||||
+ "application/vnd.elasticsearch+x-ndjson",
|
||||
+}
|
||||
+
|
||||
+
|
||||
+try:
|
||||
+ import pyarrow as pa
|
||||
+ EXPECTED_SERIALIZERS.add("application/vnd.apache.arrow.stream")
|
||||
+except ImportError:
|
||||
+ pa = None
|
||||
+
|
||||
+
|
||||
+
|
||||
def test_sniff_on_connection_fail():
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
client = Elasticsearch("http://localhost:9200", sniff_on_connection_fail=True)
|
||||
@@ -129,15 +147,7 @@ def test_serializer_and_serializers():
|
||||
client.transport.serializers.get_serializer("application/json"),
|
||||
CustomSerializer,
|
||||
)
|
||||
- assert set(client.transport.serializers.serializers.keys()) == {
|
||||
- "application/vnd.mapbox-vector-tile",
|
||||
- "application/x-ndjson",
|
||||
- "application/json",
|
||||
- "text/*",
|
||||
- "application/vnd.apache.arrow.stream",
|
||||
- "application/vnd.elasticsearch+json",
|
||||
- "application/vnd.elasticsearch+x-ndjson",
|
||||
- }
|
||||
+ assert set(client.transport.serializers.serializers.keys()) == EXPECTED_SERIALIZERS
|
||||
|
||||
client = Elasticsearch(
|
||||
"http://localhost:9200",
|
||||
@@ -150,13 +160,5 @@ def test_serializer_and_serializers():
|
||||
client.transport.serializers.get_serializer("application/json"),
|
||||
CustomSerializer,
|
||||
)
|
||||
- assert set(client.transport.serializers.serializers.keys()) == {
|
||||
- "application/vnd.mapbox-vector-tile",
|
||||
- "application/x-ndjson",
|
||||
- "application/json",
|
||||
- "text/*",
|
||||
- "application/vnd.apache.arrow.stream",
|
||||
- "application/vnd.elasticsearch+json",
|
||||
- "application/vnd.elasticsearch+x-ndjson",
|
||||
- "application/cbor",
|
||||
- }
|
||||
+ expected = EXPECTED_SERIALIZERS | {"application/cbor"}
|
||||
+ assert set(client.transport.serializers.serializers.keys()) == expected
|
||||
diff --git a/test_elasticsearch/test_client/test_serializers.py b/test_elasticsearch/test_client/test_serializers.py
|
||||
index 9d13386e..4b18212d 100644
|
||||
--- a/test_elasticsearch/test_client/test_serializers.py
|
||||
+++ b/test_elasticsearch/test_client/test_serializers.py
|
||||
@@ -21,6 +21,23 @@ from elasticsearch import Elasticsearch
|
||||
from test_elasticsearch.test_cases import DummyTransportTestCase
|
||||
|
||||
|
||||
+EXPECTED_SERIALIZERS = {
|
||||
+ "application/json",
|
||||
+ "text/*",
|
||||
+ "application/x-ndjson",
|
||||
+ "application/vnd.mapbox-vector-tile",
|
||||
+ "application/vnd.elasticsearch+json",
|
||||
+ "application/vnd.elasticsearch+x-ndjson",
|
||||
+}
|
||||
+
|
||||
+
|
||||
+try:
|
||||
+ import pyarrow as pa
|
||||
+ EXPECTED_SERIALIZERS.add("application/vnd.apache.arrow.stream")
|
||||
+except ImportError:
|
||||
+ pa = None
|
||||
+
|
||||
+
|
||||
class TestSerializers(DummyTransportTestCase):
|
||||
def test_compat_mode_on_by_default(self):
|
||||
calls = self.client.transport.calls
|
||||
@@ -90,16 +107,8 @@ class TestSerializers(DummyTransportTestCase):
|
||||
"https://localhost:9200", serializers={f"application/{mime_subtype}": ser}
|
||||
)
|
||||
serializers = client.transport.serializers.serializers
|
||||
- assert set(serializers.keys()) == {
|
||||
- "application/json",
|
||||
- "text/*",
|
||||
- "application/x-ndjson",
|
||||
- "application/vnd.apache.arrow.stream",
|
||||
- "application/vnd.mapbox-vector-tile",
|
||||
- "application/vnd.elasticsearch+json",
|
||||
- "application/vnd.elasticsearch+x-ndjson",
|
||||
- }
|
||||
|
||||
+ assert set(serializers.keys()) == EXPECTED_SERIALIZERS
|
||||
assert serializers[f"application/{mime_subtype}"] is ser
|
||||
assert serializers[f"application/vnd.elasticsearch+{mime_subtype}"] is ser
|
||||
|
||||
@@ -118,16 +127,7 @@ class TestSerializers(DummyTransportTestCase):
|
||||
},
|
||||
)
|
||||
serializers = client.transport.serializers.serializers
|
||||
- assert set(serializers.keys()) == {
|
||||
- "application/json",
|
||||
- "text/*",
|
||||
- "application/x-ndjson",
|
||||
- "application/vnd.apache.arrow.stream",
|
||||
- "application/vnd.mapbox-vector-tile",
|
||||
- "application/vnd.elasticsearch+json",
|
||||
- "application/vnd.elasticsearch+x-ndjson",
|
||||
- }
|
||||
-
|
||||
+ assert set(serializers.keys()) == EXPECTED_SERIALIZERS
|
||||
assert serializers[f"application/{mime_subtype}"] is ser1
|
||||
assert serializers[f"application/vnd.elasticsearch+{mime_subtype}"] is ser2
|
||||
|
||||
@@ -138,15 +138,6 @@ class TestSerializers(DummyTransportTestCase):
|
||||
ser = CustomSerializer()
|
||||
client = Elasticsearch("https://localhost:9200", serializer=ser)
|
||||
serializers = client.transport.serializers.serializers
|
||||
- assert set(serializers.keys()) == {
|
||||
- "application/json",
|
||||
- "text/*",
|
||||
- "application/x-ndjson",
|
||||
- "application/vnd.apache.arrow.stream",
|
||||
- "application/vnd.mapbox-vector-tile",
|
||||
- "application/vnd.elasticsearch+json",
|
||||
- "application/vnd.elasticsearch+x-ndjson",
|
||||
- }
|
||||
-
|
||||
+ assert set(serializers.keys()) == EXPECTED_SERIALIZERS
|
||||
assert serializers["application/json"] is ser
|
||||
assert serializers["application/vnd.elasticsearch+json"] is ser
|
||||
diff --git a/test_elasticsearch/test_serializer.py b/test_elasticsearch/test_serializer.py
|
||||
index 02723e8f..313029ba 100644
|
||||
--- a/test_elasticsearch/test_serializer.py
|
||||
+++ b/test_elasticsearch/test_serializer.py
|
||||
@@ -19,9 +19,14 @@ import uuid
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
|
||||
-import pyarrow as pa
|
||||
import pytest
|
||||
|
||||
+try:
|
||||
+ import pyarrow as pa
|
||||
+ from elasticsearch.serializer import PyArrowSerializer
|
||||
+except ImportError:
|
||||
+ pa = None
|
||||
+
|
||||
try:
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
@@ -35,7 +40,6 @@ from elasticsearch.exceptions import SerializationError
|
||||
from elasticsearch.serializer import (
|
||||
JSONSerializer,
|
||||
OrjsonSerializer,
|
||||
- PyArrowSerializer,
|
||||
TextSerializer,
|
||||
)
|
||||
|
||||
@@ -163,6 +167,7 @@ def test_serializes_pandas_category(json_serializer):
|
||||
assert b'{"d":[1,2,3]}' == json_serializer.dumps({"d": cat})
|
||||
|
||||
|
||||
+@pytest.mark.skipif(pa is None, reason="Test requires pyarrow to be available")
|
||||
def test_pyarrow_loads():
|
||||
data = [
|
||||
pa.array([1, 2, 3, 4]),
|
||||
--
|
||||
2.47.0
|
||||
|
BIN
v8.17.0.tar.gz
(Stored with Git LFS)
BIN
v8.17.0.tar.gz
(Stored with Git LFS)
Binary file not shown.
Reference in New Issue
Block a user