From: Miod Vallat Date: Fri, 5 Dec 2025 14:20:38 +0000 (+0100) Subject: Add latest version of assert_in_json_error for the new tests to pass. X-Git-Tag: auth-5.0.2^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04f55bf094e25135e16e52ddcd4bad4d5f876424;p=thirdparty%2Fpdns.git Add latest version of assert_in_json_error for the new tests to pass. Signed-off-by: Miod Vallat --- diff --git a/regression-tests.api/test_Zones.py b/regression-tests.api/test_Zones.py index e3d72abf65..f637ffb53e 100644 --- a/regression-tests.api/test_Zones.py +++ b/regression-tests.api/test_Zones.py @@ -80,7 +80,21 @@ def templated_rrsets(rrsets: list, zonename: str): return new_rrsets -class Zones(ApiTestCase): +class ZonesApiTestCase(ApiTestCase): + + def assert_in_json_error(self, expected, json): + error = json['error'] + if expected not in error: + found = False + if 'errors' in json: + errors = json['errors'] + for item in errors: + if expected in item: + found = True + assert found, "%r not found in %r" % (expected, errors) + assert found, "%r not found in %r" % (expected, error) + +class Zones(ZonesApiTestCase): def _test_list_zones(self, dnssec=True): path = "/api/v1/servers/localhost/zones" @@ -196,7 +210,7 @@ class AuthZonesHelperMixin(object): self.assertEqual(r.status_code, 204, r.content) @unittest.skipIf(not is_auth(), "Not applicable") -class AuthZones(ApiTestCase, AuthZonesHelperMixin): +class AuthZones(ZonesApiTestCase, AuthZonesHelperMixin): def test_create_zone(self): # soa_edit_api has a default, override with empty for this test