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

Commit 02765fa

Browse files
authored
Merge pull request #259 from snok/sondrelg/remove-sonarqube
Drop sonarqube
2 parents d0dd312 + 54b0d8b commit 02765fa

File tree

8 files changed

+22
-35
lines changed

8 files changed

+22
-35
lines changed

.github/workflows/testing.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,3 @@ jobs:
9595
file: ./coverage.xml
9696
fail_ci_if_error: true
9797
token: ${{ secrets.CODECOV_TOKEN }}
98-
- name: Fix coverage file for sonarcloud
99-
run: |
100-
sed -i "s/<source>\/home\/runner\/work\/drf-openapi-tester\/drf-openapi-tester\//<source>/g" coverage.xml
101-
cat coverage.xml
102-
- uses: sonarsource/sonarcloud-github-action@master
103-
env:
104-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.pre-commit-config.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 21.12b0
3+
rev: 22.3.0
44
hooks:
55
- id: black
6-
args: [ '--quiet' ]
76

87
- repo: https://github.com/pre-commit/pre-commit-hooks
9-
rev: v4.1.0
8+
rev: v4.2.0
109
hooks:
1110
- id: check-case-conflict
1211
- id: end-of-file-fixer
@@ -32,7 +31,7 @@ repos:
3231
]
3332

3433
- repo: https://github.com/asottile/pyupgrade
35-
rev: v2.30.0
34+
rev: v2.32.0
3635
hooks:
3736
- id: pyupgrade
3837
args: [ "--py3-plus", "--py36-plus", "--py37-plus" ]
@@ -43,7 +42,7 @@ repos:
4342
- id: isort
4443

4544
- repo: https://github.com/pre-commit/mirrors-mypy
46-
rev: 'v0.930'
45+
rev: 'v0.942'
4746
hooks:
4847
- id: mypy
4948
additional_dependencies:

openapi_tester/schema_tester.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def get_response_schema_section(self, response: Response) -> dict[str, Any]:
156156
json_object = self.get_key_value(
157157
content_object,
158158
"application/json",
159-
f"\n\nNo `application/json` responses documented for method: "
159+
"\n\nNo `application/json` responses documented for method: "
160160
f"{response_method}, path: {parameterized_path}",
161161
)
162162
return self.get_key_value(json_object, "schema")
@@ -165,8 +165,9 @@ def get_response_schema_section(self, response: Response) -> dict[str, Any]:
165165
raise UndocumentedSchemaSectionError(
166166
UNDOCUMENTED_SCHEMA_SECTION_ERROR.format(
167167
key="content",
168-
error_addon=f"\n\nNo `content` defined for this response: "
169-
f"{response_method}, path: {parameterized_path}",
168+
error_addon=(
169+
f"\n\nNo `content` defined for this response: {response_method}, path: {parameterized_path}"
170+
),
170171
)
171172
)
172173
return {}
@@ -246,7 +247,7 @@ def test_schema_section(
246247
raise DocumentationError(
247248
f"{VALIDATE_NONE_ERROR}\n\n"
248249
f"Reference: {reference}\n\n"
249-
f"Hint: Return a valid type, or document the value as nullable"
250+
"Hint: Return a valid type, or document the value as nullable"
250251
)
251252
schema_section = normalize_schema_section(schema_section)
252253
if "oneOf" in schema_section:
@@ -319,7 +320,7 @@ def test_openapi_object(
319320
raise DocumentationError(
320321
f"{VALIDATE_MISSING_RESPONSE_KEY_ERROR.format(missing_key=key)}\n\nReference: {reference}."
321322
f"object:key:{key}\n\nHint: Remove the key from your"
322-
f" OpenAPI docs, or include it in your API response"
323+
" OpenAPI docs, or include it in your API response"
323324
)
324325
for key in response_keys:
325326
self.test_key_casing(key, case_tester, ignore_case)
@@ -332,7 +333,7 @@ def test_openapi_object(
332333
raise DocumentationError(
333334
f"{VALIDATE_WRITE_ONLY_RESPONSE_KEY_ERROR.format(write_only_key=key)}\n\nReference: {reference}"
334335
f".object:key:{key}\n\nHint: Remove the key from your API response, or remove the "
335-
f'"WriteOnly" restriction'
336+
'"WriteOnly" restriction'
336337
)
337338
for key, value in data.items():
338339
if key in properties:

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ build-backend = "poetry.masonry.api"
7272

7373
[tool.black]
7474
line-length = 120
75+
preview = true
76+
quiet = true
7577
include = '\.pyi?$'
7678

7779
[tool.isort]

sonar-project.properties

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/test_errors.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def test_validate_min_properties_error(self):
3636
def test_validate_max_properties_error(self):
3737
message = validate_max_properties({"maxProperties": 1}, {"one": 1, "two": 2})
3838
assert (
39-
message == "The number of properties in {'one': 1, 'two': 2} exceeds the"
39+
message
40+
== "The number of properties in {'one': 1, 'two': 2} exceeds the"
4041
" specified maximum number of properties of 1"
4142
)
4243

@@ -111,7 +112,7 @@ def test_validate_format_error(self):
111112
({"format": "uri"}, "not uri"),
112113
({"format": "url"}, "not url"),
113114
]
114-
for (schema, data) in d:
115+
for schema, data in d:
115116
message = validate_format(schema, data)
116117
assert message == f'''Expected: a "{schema['format']}" formatted value\n\nReceived: "{data}"'''
117118

@@ -212,7 +213,7 @@ def test_any_of_error():
212213

213214
def test_one_of_error():
214215
expected_error_message = (
215-
"Expected data to match one and only one of the oneOf schema types; found 0 matches\n\n" "Reference: init.oneOf"
216+
"Expected data to match one and only one of the oneOf schema types; found 0 matches\n\nReference: init.oneOf"
216217
)
217218
tester = SchemaTester()
218219
with pytest.raises(DocumentationError, match=expected_error_message):

tests/test_schema_tester.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,10 @@ def test_validate_response_failure_scenario_undocumented_content(client, monkeyp
201201
response = client.get(de_parameterized_path)
202202
with pytest.raises(
203203
UndocumentedSchemaSectionError,
204-
match=f"Error: Unsuccessfully tried to index the OpenAPI schema by `content`. \n\n"
205-
f"No `content` defined for this response: {method}, path: {parameterized_path}",
204+
match=(
205+
"Error: Unsuccessfully tried to index the OpenAPI schema by `content`. \n\n"
206+
f"No `content` defined for this response: {method}, path: {parameterized_path}"
207+
),
206208
):
207209
tester.validate_response(response)
208210

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def iterate_schema(schema: dict) -> Generator[tuple[dict | None, Response | None
3535
with suppress(KeyError):
3636
if "content" in responses_object:
3737
schema_section = responses_object["content"]["application/json"]["schema"]
38-
elif "schema" in responses_object:
38+
elif "schema" in responses_object: # noqa: SIM908
3939
schema_section = responses_object["schema"]
4040
if schema_section:
4141
response = response_factory(

0 commit comments

Comments
 (0)