From 07c39548f848ded84bbce8455b974a5e298f1ea2 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Mon, 12 Apr 2021 19:42:31 +0200 Subject: address es hits.total change in ES7 * https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html --- tests/test_utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_utils.py b/tests/test_utils.py index 29b125b..24be9d1 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -3,7 +3,7 @@ import os from fuzzycat.utils import (author_similarity_score, cut, jaccard, nwise, slugify_string, token_n_grams, tokenize_string, parse_page_string, dict_key_exists, - zstdlines) + zstdlines, es_compat_hits_total) def test_slugify_string(): @@ -98,3 +98,12 @@ def test_zstdlines(): for zfn, fn in examples: with open(fn) as f: assert [s.strip() for s in f.readlines()] == list(zstdlines(zfn)) + +def test_es_compat_hits_total(): + cases = ( + ({"hits": {"total": 6}}, 6), + ({"hits": {"total": {"value": 7, "relation": "eq"}}}, 7), + ) + for r, expected in cases: + assert es_compat_hits_total(r) == expected + -- cgit v1.2.3