Skip to content

Commit

Permalink
Merge pull request #75 from maykinmedia/remove-support-zds-1
Browse files Browse the repository at this point in the history
⬆️ Drop support for zds-client<2
  • Loading branch information
Viicos authored Oct 11, 2023
2 parents 5b53700 + e53cd5f commit 834261b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 41 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ jobs:
matrix:
python: ['3.10', '3.11']
django: ['3.2', '4.1', '4.2']
zdsclient: ['1.0', '2.0']
exclude:
- python: '3.11'
django: '3.2'

name: Run the test suite (Python ${{ matrix.python }}, Django ${{ matrix.django }}, zds-client ${{ matrix.zdsclient }})
name: Run the test suite (Python ${{ matrix.python }}, Django ${{ matrix.django }}

services:
postgres:
Expand All @@ -54,13 +53,12 @@ jobs:

- name: Run tests
run: |
export TOXENV=py${PYTHON_VERSION/./}-django${DJANGO/./}-zdsclient${ZDS_CLIENT/./}
export TOXENV=py${PYTHON_VERSION/./}-django${DJANGO/./}
tox
codecov -e TOXENV,DJANGO,ZDS_CLIENT --file reports/coverage-${TOXENV}.xml
codecov -e TOXENV,DJANGO --file reports/coverage-${TOXENV}.xml
env:
PYTHON_VERSION: ${{ matrix.python }}
DJANGO: ${{ matrix.django }}
ZDS_CLIENT: ${{ matrix.zdsclient }}

publish:
name: Publish package to PyPI
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ install_requires =
django>=3.2.0
django-relativedelta>=2.0.0
django-solo
gemma-zds-client>=1.0.1
gemma-zds-client>=2.0.0
django-simple-certmanager>=1.4.1
requests
pyopenssl
Expand Down
10 changes: 2 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[tox]
envlist =
py37-django32-zdsclient{10,20}
py{310,311}-django{32,41,42}-zdsclient{10,20}
py311-django{41,42}-zdsclient{10,20}
py{310,311}-django{32,41,42}
py311-django{41,42}
isort
black
flake8
Expand All @@ -19,9 +18,6 @@ DJANGO =
3.2: django32
4.1: django41
4.2: django42
ZDS_CLIENT =
1.0: zdsclient10
2.0: zdsclient20

[testenv]
setenv =
Expand All @@ -42,8 +38,6 @@ deps =
django32: Django~=3.2.0
django41: Django~=4.1.0
django42: Django~=4.2.0
zdsclient10: gemma-zds-client~=1.0.0
zdsclient20: gemma-zds-client~=2.0.0
commands =
py.test -s tests \
--junitxml=reports/junit.xml \
Expand Down
18 changes: 2 additions & 16 deletions zgw_consumers/legacy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
from django.utils.module_loading import import_string

import yaml
import zds_client
from zds_client import Client
from zds_client.oas import schema_fetcher

from ..settings import get_setting

logger = logging.getLogger(__name__)

IS_OLD_ZDS_CLIENT = zds_client.__version__ < "2.0.0"

Object = Dict[str, Any]


Expand Down Expand Up @@ -67,28 +64,17 @@ def fetch_schema(self) -> None:
logger.info("Fetching schema at '%s'", url)
self._schema = schema_fetcher.fetch(url, {"v": "3"})

def pre_request(
self, method: str, url: str, kwargs: Optional[dict] = None, **old_kwargs
):
def pre_request(self, method: str, url: str, kwargs: Optional[dict] = None):
"""
Add authorization header to requests for APIs without jwt.
"""
kwargs = kwargs or {}
if old_kwargs:
warnings.warn(
"Keyword argument unpacking is removed in zds-client 2.0.",
DeprecationWarning,
)
kwargs.update(old_kwargs)

if not self.auth and self.auth_value:
headers = kwargs.get("headers", {})
headers.update(self.auth_value)

if IS_OLD_ZDS_CLIENT:
super_kwargs = kwargs
else:
super_kwargs = {"kwargs": kwargs}
super_kwargs = {"kwargs": kwargs}

return super().pre_request(method, url, **super_kwargs)

Expand Down
12 changes: 1 addition & 11 deletions zgw_consumers/models/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,7 @@ def build_client(self, **claims):
api_root = api_root.replace(self.api_root, self.nlx, 1)

Client = get_client_class()
# legacy flow
if hasattr(Client, "from_url"):
warnings.warn(
"Support for zds-client < 2.0 is deprecated", DeprecationWarning
)
dummy_detail_url = f"{api_root}dummy/{_uuid}"
client = Client.from_url(dummy_detail_url)
client.schema_url = self.oas
client.schema_file = self.oas_file
else: # 2.0.0+
client = Client(api_root, schema_url=self.oas, schema_file=self.oas_file)
client = Client(api_root, schema_url=self.oas, schema_file=self.oas_file)

if self.server_certificate:
client.server_certificate_path = (
Expand Down

0 comments on commit 834261b

Please sign in to comment.