Skip to content

Commit 00899b9

Browse files
authored
Merge pull request #35 from ShipChain/feature/remove-json-asserter
Remove JSON Asserter pytest fixture
2 parents 8e2458a + 850676b commit 00899b9

4 files changed

Lines changed: 255 additions & 292 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,3 @@ pytest-cov = "^2.6"
4444
pytest-django = "^3.6"
4545
pytest-mock = "^1.10"
4646
safety = "^1.8"
47-
48-
[tool.poetry.plugins."pytest11"]
49-
"json_asserter" = "shipchain_common.test_utils.json_asserter"

src/shipchain_common/test_utils/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
"""
1717

1818
from .json_asserter import \
19-
json_asserter, \
20-
AssertionHelper, \
21-
JsonAsserterMixin
22-
19+
AssertionHelper
2320
from .helpers import\
2421
create_form_content, \
2522
datetimeAlmostEqual, \

src/shipchain_common/test_utils/json_asserter.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
limitations under the License.
1515
"""
1616

17-
import pytest
1817
from rest_framework import status
1918

2019
# pylint: disable=too-many-branches
@@ -401,7 +400,9 @@ def assert_404(response, error='Not found', pointer=None, vnd=True):
401400
response_has_error(response, error, pointer, vnd)
402401

403402

404-
def assert_405(response, error='Method not allowed', pointer=None, vnd=True):
403+
def assert_405(response, error=None, pointer=None, vnd=True):
404+
if error is None:
405+
error = f'Method "{response.renderer_context["request"].method}" not allowed.'
405406
assert response is not None
406407
assert response.status_code == status.HTTP_405_METHOD_NOT_ALLOWED, f'status_code {response.status_code} != 405'
407408
response_has_error(response, error, pointer, vnd)
@@ -435,14 +436,3 @@ class AssertionHelper:
435436

436437
HTTP_500 = assert_500
437438
HTTP_503 = assert_503
438-
439-
440-
@pytest.fixture(scope='session')
441-
def json_asserter():
442-
return AssertionHelper
443-
444-
445-
class JsonAsserterMixin:
446-
@pytest.fixture(autouse=True)
447-
def set_json_asserter(self, json_asserter):
448-
self.json_asserter = json_asserter

0 commit comments

Comments
 (0)