Skip to content
This repository was archived by the owner on Nov 19, 2023. It is now read-only.

Commit eca2fb2

Browse files
authored
Merge pull request #223 from snok/fix-222
Replace functools cached_property wrapper with django wrapper
2 parents 6707d3a + 278053a commit eca2fb2

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v1.3.3 2020-02-25
4+
5+
* Replace Python 3.8+ functools feature with builtin Django equivalent
6+
37
## v1.3.2 2020-02-20
48

59
* Hotfix regression due to pk resolution logic

openapi_tester/loaders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import difflib
33
import json
44
import pathlib
5-
from functools import cached_property
65
from json import dumps, loads
76
from typing import Callable, Dict, List, Optional, Tuple
87
from urllib.parse import ParseResult, urlparse
98

109
import yaml
1110
from django.urls import Resolver404, ResolverMatch, resolve
11+
from django.utils.functional import cached_property
1212
from openapi_spec_validator import openapi_v2_spec_validator, openapi_v3_spec_validator
1313

1414
# noinspection PyProtectedMember
@@ -147,7 +147,7 @@ def handle_pk_parameter( # pylint: disable=no-self-use
147147
) -> Tuple[str, ResolverMatch]:
148148
coerced_path = BaseSchemaGenerator().coerce_path(path=path, method=method, view=resolved_route.func) # type: ignore
149149
pk_field_name = "".join(
150-
list([entry.replace("+ ", "") for entry in difflib.Differ().compare(path, coerced_path) if "+ " in entry])
150+
entry.replace("+ ", "") for entry in difflib.Differ().compare(path, coerced_path) if "+ " in entry
151151
)
152152
resolved_route.kwargs[pk_field_name] = resolved_route.kwargs["pk"]
153153
del resolved_route.kwargs["pk"]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "drf-openapi-tester"
3-
version = "1.3.2"
3+
version = "1.3.3"
44
description = "Django test utility for validating OpenAPI response documentation"
55
authors = ["Sondre Lillebø Gundersen <sondrelg@live.no>", "Na'aman Hirschfeld <nhirschfeld@gmail.com>"]
66
maintainers = ["Na'aman Hirschfeld <nhirschfeld@gmail.com>"]

tests/test_schema_tester.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,16 @@ def test_validate_response_failure_scenario_undocumented_status_code(monkeypatch
193193

194194

195195
def test_validate_response_global_case_tester(client):
196-
tester_with_case_tester = SchemaTester(case_tester=is_pascal_case)
197196
response = client.get(de_parameterized_path)
198-
with pytest.raises(CaseError, match="The response key `name` is not properly PascalCased. Expected value: Name"):
199-
tester_with_case_tester.validate_response(response=response)
197+
with pytest.raises(CaseError, match="is not properly PascalCased"):
198+
SchemaTester(case_tester=is_pascal_case).validate_response(response=response)
200199

201200

202201
def test_validate_response_global_ignored_case(client):
203-
tester_with_case_tester = SchemaTester(
204-
case_tester=is_pascal_case, ignore_case=["name", "color", "height", "width", "length"]
205-
)
206202
response = client.get(de_parameterized_path)
207-
tester_with_case_tester.validate_response(response=response)
203+
SchemaTester(
204+
case_tester=is_pascal_case, ignore_case=["name", "color", "height", "width", "length"]
205+
).validate_response(response=response)
208206

209207

210208
def test_validate_response_passed_in_case_tester(client):

0 commit comments

Comments
 (0)