From f39838af7c189151f9fed8fbff3efd61c785fbd0 Mon Sep 17 00:00:00 2001
From: Erwan Rouchet <rouchet@teklia.com>
Date: Thu, 9 Mar 2023 17:20:23 +0000
Subject: [PATCH] Fix distutils warnings and add bump-bot

---
 .gitlab-ci.yml           |  2 +-
 tests-requirements.txt   |  3 +++
 tests/test_pagination.py | 34 +++++++++++++++++++---------------
 tox.ini                  |  5 +----
 4 files changed, 24 insertions(+), 20 deletions(-)
 create mode 100644 tests-requirements.txt

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d5bb9df..1297caf 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -100,4 +100,4 @@ bump-python-deps:
     - schedules
 
   script:
-    - devops python-deps requirements.txt
+    - devops python-deps requirements.txt tests-requirements.txt
diff --git a/tests-requirements.txt b/tests-requirements.txt
new file mode 100644
index 0000000..b38c584
--- /dev/null
+++ b/tests-requirements.txt
@@ -0,0 +1,3 @@
+pytest==7.2.2
+pytest-mock==3.10.0
+pytest-responses==0.5.1
diff --git a/tests/test_pagination.py b/tests/test_pagination.py
index fb0fcb0..ae78ad7 100644
--- a/tests/test_pagination.py
+++ b/tests/test_pagination.py
@@ -4,6 +4,7 @@ from pathlib import Path
 
 import pytest
 import responses
+from responses import matchers
 
 from arkindex import ArkindexClient
 from arkindex.pagination import PaginationMode
@@ -59,7 +60,7 @@ def test_page_pagination_with_missing_data(mock_schema, monkeypatch):
     responses.add(
         responses.GET,
         base_url,
-        match_querystring=True,
+        match=[matchers.query_param_matcher({})],
         json={
             "count": 9,
             "number": 1,
@@ -74,7 +75,8 @@ def test_page_pagination_with_missing_data(mock_schema, monkeypatch):
     for i in range(3):
         responses.add(
             responses.GET,
-            f"{base_url}?page=2",
+            base_url,
+            match=[matchers.query_param_matcher({"page": 2})],
             status=400,
             json={"error": "some error happened"},
         )
@@ -82,12 +84,12 @@ def test_page_pagination_with_missing_data(mock_schema, monkeypatch):
     # Page 3
     responses.add(
         responses.GET,
-        f"{base_url}?page=3",
-        match_querystring=True,
+        base_url,
+        match=[matchers.query_param_matcher({"page": 3})],
         json={
             "count": 9,
             "number": 3,
-            "previous": f"{base_url}?page=2",
+            "previous": f"{base_url}?page=3",
             "next": None,
             "results": [7, 8, 9],
         },
@@ -123,7 +125,7 @@ def test_page_pagination_incomplete(mock_schema, monkeypatch):
     responses.add(
         responses.GET,
         base_url,
-        match_querystring=True,
+        match=[matchers.query_param_matcher({})],
         json={
             "count": 9,
             "number": 1,
@@ -137,7 +139,8 @@ def test_page_pagination_incomplete(mock_schema, monkeypatch):
     # Page 3 is not needed as it won't try to load it
     responses.add(
         responses.GET,
-        f"{base_url}?page=2",
+        base_url,
+        match=[matchers.query_param_matcher({"page": 2})],
         status=500,
     )
 
@@ -160,8 +163,8 @@ def test_cursor_pagination_length(mock_schema):
 
     responses.add(
         responses.GET,
-        f"{base_url}?with_count=true",
-        match_querystring=True,
+        base_url,
+        match=[matchers.query_param_matcher({"with_count": "true"})],
         json={
             "count": 6,
             "previous": None,
@@ -171,8 +174,8 @@ def test_cursor_pagination_length(mock_schema):
     )
     responses.add(
         responses.GET,
-        f"{base_url}?cursor=DEF",
-        match_querystring=True,
+        base_url,
+        match=[matchers.query_param_matcher({"cursor": "DEF"})],
         json={
             "count": None,
             "previous": f"{base_url}?cursor=ABC",
@@ -198,8 +201,8 @@ def test_cursor_pagination_zero_results(mock_schema):
     base_url = "https://dummy.test/api/v1/process/process_id/elements/"
     responses.add(
         responses.GET,
-        f"{base_url}?with_count=true",
-        match_querystring=True,
+        base_url,
+        match=[matchers.query_param_matcher({"with_count": "true"})],
         json={
             "count": 0,
             "previous": None,
@@ -223,7 +226,8 @@ def test_cursor_pagination_len_errors(mock_schema, mocker):
     base_url = "https://dummy.test/api/v1/process/process_id/elements/"
     responses.add(
         responses.GET,
-        f"{base_url}?with_count=true",
+        base_url,
+        match=[matchers.query_param_matcher({"with_count": "true"})],
         status=500,
     )
 
@@ -244,7 +248,7 @@ def test_paginate_x_paginated(mock_schema):
     responses.add(
         responses.GET,
         "https://dummy.test/api/v1/element/element_id/metadata/",
-        match_querystring=True,
+        match=[matchers.query_param_matcher({})],
         json=["a", "b"],
     )
 
diff --git a/tox.ini b/tox.ini
index f585be6..4707cae 100644
--- a/tox.ini
+++ b/tox.ini
@@ -6,7 +6,4 @@ passenv = ARKINDEX_API_SCHEMA_URL
 commands =
 	pytest {posargs}
 
-deps =
-	pytest
-	pytest-responses
-	pytest-mock
+deps = -rtests-requirements.txt
-- 
GitLab