mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 23:46:05 -03:30
Update unit tests
This commit is contained in:
@@ -1929,35 +1929,34 @@ def test_notification_job_finished(mocker):
|
|||||||
uj.send_notification_templates.assert_called()
|
uj.send_notification_templates.assert_called()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
def test_job_run_no_ee(execution_environment, private_data_dir, job):
|
||||||
class TestNullExecutionEnvironment(TestJobExecution):
|
org = Organization(pk=1)
|
||||||
def test_job_run_no_ee(self, execution_environment, private_data_dir, job):
|
proj = Project(pk=1, organization=org)
|
||||||
org = Organization(pk=1)
|
job = Job(project=proj, organization=org, inventory=Inventory(pk=1))
|
||||||
proj = Project(pk=1, organization=org)
|
job.execution_environment = None
|
||||||
job = Job(project=proj, organization=org, inventory=Inventory(pk=1))
|
task = tasks.RunJob()
|
||||||
job.execution_environment = None
|
task.instance = job
|
||||||
task = tasks.RunJob()
|
task.update_model = mock.Mock(return_value=job)
|
||||||
task.instance = job
|
task.model.objects.get = mock.Mock(return_value=job)
|
||||||
task.update_model = mock.Mock(return_value=job)
|
|
||||||
task.model.objects.get = mock.Mock(return_value=job)
|
|
||||||
|
|
||||||
with mock.patch('awx.main.tasks.copy_tree'):
|
|
||||||
with pytest.raises(RuntimeError) as e:
|
|
||||||
task.pre_run_hook(job, private_data_dir)
|
|
||||||
|
|
||||||
update_model_call = task.update_model.call_args[1]
|
|
||||||
assert update_model_call['status'] == 'error'
|
|
||||||
assert 'Job could not start because no Execution Environment could be found' in str(e.value)
|
|
||||||
|
|
||||||
def test_project_update_no_ee(self, execution_environment, job):
|
|
||||||
org = Organization(pk=1)
|
|
||||||
proj = Project(pk=1, organization=org)
|
|
||||||
project_update = ProjectUpdate(pk=1, project=proj, scm_type='git')
|
|
||||||
project_update.execution_environment = None
|
|
||||||
task = tasks.RunProjectUpdate()
|
|
||||||
task.instance = project_update
|
|
||||||
|
|
||||||
|
with mock.patch('awx.main.tasks.copy_tree'):
|
||||||
with pytest.raises(RuntimeError) as e:
|
with pytest.raises(RuntimeError) as e:
|
||||||
task.build_env(job, {})
|
task.pre_run_hook(job, private_data_dir)
|
||||||
|
|
||||||
assert 'The project could not sync because there is no Execution Environment' in str(e.value)
|
update_model_call = task.update_model.call_args[1]
|
||||||
|
assert update_model_call['status'] == 'error'
|
||||||
|
assert 'Job could not start because no Execution Environment could be found' in str(e.value)
|
||||||
|
|
||||||
|
|
||||||
|
def test_project_update_no_ee(execution_environment, job):
|
||||||
|
org = Organization(pk=1)
|
||||||
|
proj = Project(pk=1, organization=org)
|
||||||
|
project_update = ProjectUpdate(pk=1, project=proj, scm_type='git')
|
||||||
|
project_update.execution_environment = None
|
||||||
|
task = tasks.RunProjectUpdate()
|
||||||
|
task.instance = project_update
|
||||||
|
|
||||||
|
with pytest.raises(RuntimeError) as e:
|
||||||
|
task.build_env(job, {})
|
||||||
|
|
||||||
|
assert 'The project could not sync because there is no Execution Environment' in str(e.value)
|
||||||
|
|||||||
Reference in New Issue
Block a user