mirror of
https://github.com/ansible/awx.git
synced 2026-06-23 07:37:50 -02:30
add projects to test that ordering functions correctly and when it gets a value it cannot order by it falls back to ID
add tests that check ordering for projects, organizations, inventories, groups, and hosts
This commit is contained in:
@@ -71,6 +71,17 @@ def test_organization_list_integrity(organization, get, admin, alice):
|
||||
assert field in res.data['results'][0]
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_organization_list_order_integrity(organizations, get, admin):
|
||||
# check that the order of the organization list retains integrity.
|
||||
orgs = organizations(4)
|
||||
org_ids = {}
|
||||
for x in range(3):
|
||||
res = get(reverse('api:organization_list'), user=admin).data['results']
|
||||
org_ids[x] = [org['id'] for org in res]
|
||||
assert org_ids[0] == org_ids[1] == org_ids[2] == [orgs[0].id, orgs[1].id, orgs[2].id, orgs[3].id]
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_organization_list_visibility(organizations, get, admin, alice):
|
||||
orgs = organizations(2)
|
||||
@@ -127,6 +138,18 @@ def test_organization_inventory_list(organization, inventory_factory, get, alice
|
||||
get(reverse('api:organization_inventories_list', kwargs={'pk': organization.id}), user=rando, expect=403)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_organization_inventory_list_order_integrity(organization, admin, inventory_factory, get):
|
||||
inv1 = inventory_factory('inventory')
|
||||
inv2 = inventory_factory('inventory2')
|
||||
inv3 = inventory_factory('inventory3')
|
||||
inv_ids = {}
|
||||
for x in range(3):
|
||||
res = get(reverse('api:organization_inventories_list', kwargs={'pk': organization.id}), user=admin).data['results']
|
||||
inv_ids[x] = [inv['id'] for inv in res]
|
||||
assert inv_ids[0] == inv_ids[1] == inv_ids[2] == [inv1.id, inv2.id, inv3.id]
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_create_organization(post, admin, alice):
|
||||
new_org = {'name': 'new org', 'description': 'my description'}
|
||||
|
||||
Reference in New Issue
Block a user