mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-06-16 13:06:06 +00:00
Fix tests
Increased the version of pytest to make it work with py 3.10 [0]. The GET calls no longer return list but the object itself, fixed the tests and assertions to account for that. The tests did not account for the later added `allow_user_remove_domain` setting. And there were issues with missing and non-stopped patchers/mocks. Now all tests are at least passing. [0] https://github.com/pytest-dev/pytest/pull/8540
This commit is contained in:
@ -14,8 +14,10 @@ class IntegrationApiManagement(object):
|
||||
assert res.status_code == status_code
|
||||
if res.status_code == 200:
|
||||
data = res.get_json(force=True)
|
||||
assert len(data) == 1
|
||||
return data[0]
|
||||
assert isinstance(data, dict)
|
||||
assert len(data) == 7
|
||||
assert data.get('id', None)
|
||||
return data
|
||||
return None
|
||||
|
||||
def check_account(self, cmpdata, data=None):
|
||||
@ -37,8 +39,10 @@ class IntegrationApiManagement(object):
|
||||
assert res.status_code == status_code
|
||||
if status_code == 200:
|
||||
data = res.get_json(force=True)
|
||||
assert len(data) == 1
|
||||
return data[0]
|
||||
assert isinstance(data, dict)
|
||||
assert len(data) == 7
|
||||
assert data.get('id', None)
|
||||
return data
|
||||
return None
|
||||
|
||||
def check_user(self, cmpdata, data=None):
|
||||
@ -50,5 +54,5 @@ class IntegrationApiManagement(object):
|
||||
elif key == 'role':
|
||||
assert data[key]['name'] == cmpdata['role_name']
|
||||
else:
|
||||
assert key in ("id",)
|
||||
assert key in ("id","accounts",)
|
||||
return data
|
||||
|
@ -89,8 +89,9 @@ class TestIntegrationApiManagementAdminUser(IntegrationApiManagement):
|
||||
)
|
||||
data = res.get_json(force=True)
|
||||
assert res.status_code == 200
|
||||
assert len(data) == 1
|
||||
data = data[0]
|
||||
assert isinstance(data, dict)
|
||||
assert len(data) == 7
|
||||
assert data.get('id', None)
|
||||
account_id = data["id"]
|
||||
for key, value in account_data.items():
|
||||
assert data[key] == value
|
||||
@ -142,10 +143,12 @@ class TestIntegrationApiManagementAdminUser(IntegrationApiManagement):
|
||||
)
|
||||
data = res.get_json(force=True)
|
||||
assert res.status_code == 201
|
||||
assert len(data) == 1
|
||||
assert isinstance(data, dict)
|
||||
assert len(data) == 6
|
||||
assert data.get('id', None)
|
||||
|
||||
# Check user
|
||||
user1 = self.check_user(user1_data, data[0])
|
||||
user1 = self.check_user(user1_data, data)
|
||||
user1_id = user1["id"]
|
||||
|
||||
updated = user1_data.copy()
|
||||
@ -240,10 +243,12 @@ class TestIntegrationApiManagementAdminUser(IntegrationApiManagement):
|
||||
)
|
||||
data = res.get_json(force=True)
|
||||
assert res.status_code == 201
|
||||
assert len(data) == 1
|
||||
assert isinstance(data, dict)
|
||||
assert len(data) == 6
|
||||
assert data.get('id', None)
|
||||
|
||||
# Check user
|
||||
user1 = self.check_user(user1_data, data[0])
|
||||
user1 = self.check_user(user1_data, data)
|
||||
user1_id = user1["id"]
|
||||
|
||||
# Assert test account has no users
|
||||
|
@ -33,8 +33,8 @@ class TestIntegrationApiManagementUser(IntegrationApiManagement):
|
||||
headers=basic_auth_user_headers)
|
||||
data = res.get_json(force=True)
|
||||
assert res.status_code == 200
|
||||
assert len(data) == 1, data
|
||||
self.user = data
|
||||
assert data
|
||||
self.user = [data]
|
||||
|
||||
def test_accounts(
|
||||
self, client, initial_data, # noqa: F811
|
||||
@ -118,10 +118,12 @@ class TestIntegrationApiManagementUser(IntegrationApiManagement):
|
||||
)
|
||||
data = res.get_json(force=True)
|
||||
assert res.status_code == 201
|
||||
assert len(data) == 1
|
||||
assert isinstance(data, dict)
|
||||
assert len(data) == 6
|
||||
assert data.get('id', None)
|
||||
|
||||
# Check user
|
||||
user1 = self.check_user(user1_data, data[0])
|
||||
user1 = self.check_user(user1_data, data)
|
||||
user1_id = user1["id"]
|
||||
|
||||
# Update to defaults (should fail)
|
||||
@ -181,10 +183,12 @@ class TestIntegrationApiManagementUser(IntegrationApiManagement):
|
||||
)
|
||||
data = res.get_json(force=True)
|
||||
assert res.status_code == 201
|
||||
assert len(data) == 1
|
||||
assert isinstance(data, dict)
|
||||
assert len(data) == 6
|
||||
assert data.get('id', None)
|
||||
|
||||
# Check user
|
||||
user1 = self.check_user(user1_data, data[0])
|
||||
user1 = self.check_user(user1_data, data)
|
||||
user1_id = user1["id"]
|
||||
|
||||
# Assert test account has no users
|
||||
|
Reference in New Issue
Block a user