block job template launches when an inventory is being deleted

see: #4382
This commit is contained in:
Ryan Petrello
2017-06-22 15:26:31 -04:00
parent 14addae813
commit 97562fc4df
3 changed files with 42 additions and 0 deletions

View File

@@ -472,6 +472,23 @@ def test_scan_jt_surveys(inventory):
assert "survey_enabled" in serializer.errors
@pytest.mark.django_db
def test_launch_with_pending_deletion_inventory(get, post, organization_factory,
job_template_factory, machine_credential,
credential, net_credential):
objs = organization_factory("org", superusers=['admin'])
jt = job_template_factory("jt", organization=objs.organization, credential='c',
inventory='test_inv', project='test_proj').job_template
jt.inventory.pending_deletion = True
jt.inventory.save()
resp = post(
reverse('api:job_template_launch', kwargs={'pk': jt.pk}),
objs.superusers.admin, expect=400
)
assert resp.data['inventory'] == ['The inventory associated with this Job Template is being deleted.']
@pytest.mark.django_db
def test_launch_with_extra_credentials(get, post, organization_factory,
job_template_factory, machine_credential,