From bde7000a283ee8adecd6d50d538027b35588a394 Mon Sep 17 00:00:00 2001
From: Valentin Rigal <rigal@teklia.com>
Date: Wed, 23 Feb 2022 20:44:49 +0000
Subject: [PATCH] Update with_classes parameter

---
 arkindex_worker/worker/element.py           | 16 ++++------------
 tests/test_elements_worker/test_elements.py | 17 +++--------------
 2 files changed, 7 insertions(+), 26 deletions(-)

diff --git a/arkindex_worker/worker/element.py b/arkindex_worker/worker/element.py
index 747af95b..a89528ba 100644
--- a/arkindex_worker/worker/element.py
+++ b/arkindex_worker/worker/element.py
@@ -188,12 +188,11 @@ class ElementMixin(object):
     def list_element_children(
         self,
         element,
-        best_class=None,
         folder=None,
         name=None,
         recursive=None,
         type=None,
-        with_best_classes=None,
+        with_classes=None,
         with_corpus=None,
         with_has_children=None,
         with_zone=None,
@@ -206,11 +205,6 @@ class ElementMixin(object):
             element, (Element, CachedElement)
         ), "element shouldn't be null and should be an Element or CachedElement"
         query_params = {}
-        if best_class is not None:
-            assert isinstance(best_class, str) or isinstance(
-                best_class, bool
-            ), "best_class should be of type str or bool"
-            query_params["best_class"] = best_class
         if folder is not None:
             assert isinstance(folder, bool), "folder should be of type bool"
             query_params["folder"] = folder
@@ -223,11 +217,9 @@ class ElementMixin(object):
         if type:
             assert isinstance(type, str), "type should be of type str"
             query_params["type"] = type
-        if with_best_classes is not None:
-            assert isinstance(
-                with_best_classes, bool
-            ), "with_best_classes should be of type bool"
-            query_params["with_best_classes"] = with_best_classes
+        if with_classes is not None:
+            assert isinstance(with_classes, bool), "with_classes should be of type bool"
+            query_params["with_classes"] = with_classes
         if with_corpus is not None:
             assert isinstance(with_corpus, bool), "with_corpus should be of type bool"
             query_params["with_corpus"] = with_corpus
diff --git a/tests/test_elements_worker/test_elements.py b/tests/test_elements_worker/test_elements.py
index 02c04ca3..6e2f132b 100644
--- a/tests/test_elements_worker/test_elements.py
+++ b/tests/test_elements_worker/test_elements.py
@@ -976,17 +976,6 @@ def test_list_element_children_wrong_element(mock_elements_worker):
     )
 
 
-def test_list_element_children_wrong_best_class(mock_elements_worker):
-    elt = Element({"id": "12341234-1234-1234-1234-123412341234"})
-
-    with pytest.raises(AssertionError) as e:
-        mock_elements_worker.list_element_children(
-            element=elt,
-            best_class=1234,
-        )
-    assert str(e.value) == "best_class should be of type str or bool"
-
-
 def test_list_element_children_wrong_folder(mock_elements_worker):
     elt = Element({"id": "12341234-1234-1234-1234-123412341234"})
 
@@ -1031,15 +1020,15 @@ def test_list_element_children_wrong_type(mock_elements_worker):
     assert str(e.value) == "type should be of type str"
 
 
-def test_list_element_children_wrong_with_best_classes(mock_elements_worker):
+def test_list_element_children_wrong_with_classes(mock_elements_worker):
     elt = Element({"id": "12341234-1234-1234-1234-123412341234"})
 
     with pytest.raises(AssertionError) as e:
         mock_elements_worker.list_element_children(
             element=elt,
-            with_best_classes="not bool",
+            with_classes="not bool",
         )
-    assert str(e.value) == "with_best_classes should be of type bool"
+    assert str(e.value) == "with_classes should be of type bool"
 
 
 def test_list_element_children_wrong_with_corpus(mock_elements_worker):
-- 
GitLab