From ab98be5e114748d146b6d3e3f9a2745f2a545e5a Mon Sep 17 00:00:00 2001
From: NolanB <nboukachab@teklia.com>
Date: Fri, 8 Jul 2022 14:37:54 +0200
Subject: [PATCH] Remove the self.features from elementsWorker as well as its
 associated tests

---
 arkindex_worker/worker/base.py            |  6 +-----
 tests/conftest.py                         | 25 +----------------------
 tests/test_base_worker.py                 | 13 +++---------
 tests/test_elements_worker/__init__.py    |  1 -
 tests/test_elements_worker/test_worker.py |  6 ++----
 5 files changed, 7 insertions(+), 44 deletions(-)

diff --git a/arkindex_worker/worker/base.py b/arkindex_worker/worker/base.py
index 8e6113d5..249297b5 100644
--- a/arkindex_worker/worker/base.py
+++ b/arkindex_worker/worker/base.py
@@ -147,11 +147,6 @@ class BaseWorker(object):
         self.api_client = ArkindexClient(**options_from_env())
         logger.debug(f"Setup Arkindex API client on {self.api_client.document.url}")
 
-        # Load features available on backend, and check authentication
-        user = self.request("RetrieveUser")
-        logger.debug(f"Connected as {user['display_name']} - {user['email']}")
-        self.features = user["features"]
-
         # Load process information except in developer mode
         if not self.args.dev:
             assert os.environ.get(
@@ -207,6 +202,7 @@ class BaseWorker(object):
                     "RetrieveWorkerConfiguration", id=configuration_id
                 )
                 self.user_configuration = worker_configuration.get("configuration")
+
                 if self.user_configuration:
                     logger.info("Loaded user configuration from WorkerRun")
 
diff --git a/tests/conftest.py b/tests/conftest.py
index ab72a9ee..b82138f8 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -109,7 +109,7 @@ def give_env_variable(request, monkeypatch):
 
 
 @pytest.fixture
-def mock_config_api(mock_worker_version_api, mock_process_api, mock_user_api):
+def mock_config_api(mock_worker_version_api, mock_process_api):
     """Mock all API endpoints required to configure a worker"""
     pass
 
@@ -223,29 +223,6 @@ def mock_process_api(responses):
     )
 
 
-@pytest.fixture
-def mock_user_api(responses):
-    """
-    Provide a mock API response to retrieve user details
-    Signup is disabled in this mock
-    """
-    payload = {
-        "id": 1,
-        "email": "bot@teklia.com",
-        "display_name": "Bender",
-        "features": {
-            "signup": False,
-        },
-    }
-    responses.add(
-        responses.GET,
-        "http://testserver/api/v1/user/",
-        status=200,
-        body=json.dumps(payload),
-        content_type="application/json",
-    )
-
-
 @pytest.fixture
 def mock_activity_calls(responses):
     """
diff --git a/tests/test_base_worker.py b/tests/test_base_worker.py
index fbcbfb45..cfc7e636 100644
--- a/tests/test_base_worker.py
+++ b/tests/test_base_worker.py
@@ -45,9 +45,7 @@ def test_init_var_ponos_data_given(monkeypatch):
     assert worker.worker_version_id == "12341234-1234-1234-1234-123412341234"
 
 
-def test_init_var_worker_version_id_missing(
-    monkeypatch, mock_user_api, mock_process_api
-):
+def test_init_var_worker_version_id_missing(monkeypatch, mock_process_api):
     monkeypatch.setattr(sys, "argv", ["worker"])
     monkeypatch.delenv("WORKER_VERSION_ID")
     worker = BaseWorker()
@@ -57,9 +55,7 @@ def test_init_var_worker_version_id_missing(
     assert worker.config == {}  # default empty case
 
 
-def test_init_var_worker_local_file(
-    monkeypatch, tmp_path, mock_user_api, mock_process_api
-):
+def test_init_var_worker_local_file(monkeypatch, tmp_path, mock_process_api):
     # Build a dummy yaml config file
     config = tmp_path / "config.yml"
     config.write_text("---\nlocalKey: abcdef123")
@@ -119,9 +115,7 @@ def test_cli_arg_verbose_given(mocker, mock_config_api):
     logger.setLevel(logging.NOTSET)
 
 
-def test_configure_dev_mode(
-    mocker, monkeypatch, mock_user_api, mock_worker_version_api
-):
+def test_configure_dev_mode(mocker, monkeypatch, mock_worker_version_api):
     """
     Configuring a worker in developer mode avoid retrieving process information
     """
@@ -164,7 +158,6 @@ def test_configure_user_configuration_defaults(
     mocker,
     monkeypatch,
     mock_worker_version_user_configuration_api,
-    mock_user_api,
     mock_process_api,
     responses,
 ):
diff --git a/tests/test_elements_worker/__init__.py b/tests/test_elements_worker/__init__.py
index 2c237b93..3748d0a2 100644
--- a/tests/test_elements_worker/__init__.py
+++ b/tests/test_elements_worker/__init__.py
@@ -1,7 +1,6 @@
 # -*- coding: utf-8 -*-
 # API calls during worker configuration
 BASE_API_CALLS = [
-    ("GET", "http://testserver/api/v1/user/"),
     ("GET", "http://testserver/api/v1/imports/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff/"),
     (
         "GET",
diff --git a/tests/test_elements_worker/test_worker.py b/tests/test_elements_worker/test_worker.py
index 5289d678..ea115955 100644
--- a/tests/test_elements_worker/test_worker.py
+++ b/tests/test_elements_worker/test_worker.py
@@ -79,9 +79,7 @@ def test_readonly(responses, mock_elements_worker):
     ] == BASE_API_CALLS
 
 
-def test_activities_disabled(
-    responses, monkeypatch, mock_worker_version_api, mock_user_api
-):
+def test_activities_disabled(responses, monkeypatch, mock_worker_version_api):
     """Test worker process elements without updating activities when they are disabled for the process"""
     responses.add(
         responses.GET,
@@ -101,7 +99,7 @@ def test_activities_disabled(
     ] == BASE_API_CALLS
 
 
-def test_activities_dev_mode(mocker, mock_user_api, mock_worker_version_api):
+def test_activities_dev_mode(mocker, mock_worker_version_api):
     """
     Worker activities are not stored in dev mode
     """
-- 
GitLab