From 4afd0672a17440d1e4b06e78a6f34d5d31aaf848 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Tue, 12 Feb 2019 15:08:48 -0500 Subject: [PATCH] Add test that AWX doesn't care about the limit when creating new hosts --- .../tests/functional/api/test_inventory.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/awx/main/tests/functional/api/test_inventory.py b/awx/main/tests/functional/api/test_inventory.py index 23ed3a4f7d..9bac17b4a2 100644 --- a/awx/main/tests/functional/api/test_inventory.py +++ b/awx/main/tests/functional/api/test_inventory.py @@ -326,6 +326,24 @@ def test_create_inventory_host(post, inventory, alice, role_field, expected_stat post(reverse('api:inventory_hosts_list', kwargs={'pk': inventory.id}), data, alice, expect=expected_status_code) +@pytest.mark.parametrize("hosts,expected_status_code", [ + (1, 201), + (2, 201), + (3, 201), +]) +@pytest.mark.django_db +def test_create_inventory_host_with_limits(post, admin_user, inventory, hosts, expected_status_code): + # The per-Organization host limits functionality should be a no-op on AWX. + inventory.organization.max_hosts = 2 + inventory.organization.save() + for i in range(hosts): + inventory.hosts.create(name="Existing host %i" % i) + + data = {'name': 'New name', 'description': 'Hello world'} + post(reverse('api:inventory_hosts_list', kwargs={'pk': inventory.id}), + data, admin_user, expect=expected_status_code) + + @pytest.mark.parametrize("role_field,expected_status_code", [ (None, 403), ('admin_role', 201),