selectively show POST in options for inventory sublists

This commit is contained in:
AlanCoding
2016-08-30 10:11:51 -04:00
parent 381e8aacdd
commit 0151967e9c
2 changed files with 20 additions and 9 deletions

View File

@@ -2,13 +2,21 @@ import pytest
from django.core.urlresolvers import reverse
@pytest.fixture
def test_inventory_group_add(inventory, alice, bob, options):
inventory.admin_role.add(alice)
response = options(reverse('api:inventory_detail', args=[inventory.pk]), alice)
print ' resp: ' + str(response.data)
assert 'POST' in response.data
@pytest.mark.django_db
def test_inventory_group_host_can_add(inventory, alice, options):
inventory.admin_role.members.add(alice)
inventory.read_role.add(bob)
response = options(reverse('api:inventory_hosts_list', args=[inventory.pk]), alice)
assert 'POST' in response.data['actions']
response = options(reverse('api:inventory_groups_list', args=[inventory.pk]), alice)
assert 'POST' in response.data['actions']
@pytest.mark.django_db
def test_inventory_group_host_can_not_add(inventory, bob, options):
inventory.read_role.members.add(bob)
response = options(reverse('api:inventory_hosts_list', args=[inventory.pk]), bob)
assert 'POST' not in response.data['actions']
response = options(reverse('api:inventory_groups_list', args=[inventory.pk]), bob)
assert 'POST' not in response.data['actions']