From d5a3951d52841c40b25d353f1b460590415e7a0a Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Wed, 27 Apr 2016 15:58:16 -0400 Subject: [PATCH] break up test into 2, isolating context --- .../functional/api/test_job_runtime_params.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/awx/main/tests/functional/api/test_job_runtime_params.py b/awx/main/tests/functional/api/test_job_runtime_params.py index e90c8913d2..bd79c7aab3 100644 --- a/awx/main/tests/functional/api/test_job_runtime_params.py +++ b/awx/main/tests/functional/api/test_job_runtime_params.py @@ -175,20 +175,11 @@ def test_job_launch_fails_without_inventory(deploy_jobtemplate, post, user): @pytest.mark.django_db @pytest.mark.job_runtime_vars -def test_job_launch_fails_without_inventory_or_cred_access( - job_template_prompts, runtime_data, post, user, mocker): +def test_job_launch_fails_without_inventory_access(job_template_prompts, runtime_data, post, user): job_template = job_template_prompts(True) common_user = user('test-user', False) job_template.execute_role.members.add(common_user) - # Assure that the base job template can be launched to begin with - mock_job = mocker.MagicMock(spec=Job, id=968) - with mocker.patch('awx.main.models.unified_jobs.UnifiedJobTemplate.create_unified_job', return_value=mock_job): - with mocker.patch('awx.api.serializers.JobSerializer.to_representation'): - response = post(reverse('api:job_template_launch', args=[job_template.pk]), {}, common_user) - - assert response.status_code == 201 - # Assure that giving an inventory without access to the inventory blocks the launch runtime_inventory = Inventory.objects.get(pk=runtime_data['inventory']) response = post(reverse('api:job_template_launch', args=[job_template.pk]), @@ -197,6 +188,13 @@ def test_job_launch_fails_without_inventory_or_cred_access( assert response.status_code == 403 assert response.data['detail'] == u'You do not have permission to perform this action.' +@pytest.mark.django_db +@pytest.mark.job_runtime_vars +def test_job_launch_fails_without_credential_access(job_template_prompts, runtime_data, post, user): + job_template = job_template_prompts(True) + common_user = user('test-user', False) + job_template.execute_role.members.add(common_user) + # Assure that giving a credential without access blocks the launch runtime_credential = Credential.objects.get(pk=runtime_data['credential']) response = post(reverse('api:job_template_launch', args=[job_template.pk]),