mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
Update the Organization API list and detail tests to check the host counts
This commit is contained in:
parent
df8a66e504
commit
f5d7ca6913
@ -1,3 +1,5 @@
|
||||
import itertools
|
||||
|
||||
import pytest
|
||||
|
||||
from awx.api.versioning import reverse
|
||||
@ -17,7 +19,10 @@ def organization_resource_creator(organization, user):
|
||||
for i in range(teams):
|
||||
organization.teams.create(name='org-team %s' % i)
|
||||
for i in range(inventories):
|
||||
inventory = organization.inventories.create(name="associated-inv %s" % i)
|
||||
organization.inventories.create(name="associated-inv %s" % i)
|
||||
for i, inventory in zip(range(hosts), itertools.cycle(organization.inventories.all())):
|
||||
# evenly distribute the hosts over all of the org's inventories
|
||||
inventory.hosts.create(name="host %s" % i)
|
||||
for i in range(projects):
|
||||
organization.projects.create(name="test-proj %s" % i,
|
||||
description="test-proj-desc")
|
||||
@ -49,7 +54,7 @@ COUNTS_PRIMES = {
|
||||
'projects': 3,
|
||||
'inventories': 7,
|
||||
'teams': 5,
|
||||
'hosts': 0,
|
||||
'hosts': 7,
|
||||
}
|
||||
COUNTS_ZEROS = {
|
||||
'users': 0,
|
||||
@ -86,6 +91,7 @@ def test_org_counts_detail_member(resourced_organization, user, get):
|
||||
response = get(reverse('api:organization_detail',
|
||||
kwargs={'pk': resourced_organization.pk}), member_user)
|
||||
assert response.status_code == 200
|
||||
assert response.data['max_hosts'] == 0
|
||||
|
||||
counts = response.data['summary_fields']['related_field_counts']
|
||||
assert counts == {
|
||||
@ -95,7 +101,7 @@ def test_org_counts_detail_member(resourced_organization, user, get):
|
||||
'projects': 0,
|
||||
'inventories': 0,
|
||||
'teams': 0,
|
||||
'hosts': 0,
|
||||
'hosts': 7,
|
||||
}
|
||||
|
||||
|
||||
@ -117,9 +123,9 @@ def test_org_counts_list_member(resourced_organization, user, get):
|
||||
member_user = resourced_organization.member_role.members.get(username='org-member 1')
|
||||
response = get(reverse('api:organization_list'), member_user)
|
||||
assert response.status_code == 200
|
||||
assert response.data['results'][0]['max_hosts'] == 0
|
||||
|
||||
counts = response.data['results'][0]['summary_fields']['related_field_counts']
|
||||
|
||||
assert counts == {
|
||||
'users': COUNTS_PRIMES['users'], # Policy is that members can see other users and admins
|
||||
'admins': COUNTS_PRIMES['admins'],
|
||||
@ -127,7 +133,7 @@ def test_org_counts_list_member(resourced_organization, user, get):
|
||||
'projects': 0,
|
||||
'inventories': 0,
|
||||
'teams': 0,
|
||||
'hosts': 0,
|
||||
'hosts': 7,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user