1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 01:21:21 +03:00

add test for ScheduleAccess prompts

This commit is contained in:
AlanCoding 2018-02-21 13:40:23 -05:00
parent de4e95f396
commit 992d7831b1
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B

View File

@ -275,3 +275,24 @@ class TestJobTemplateSchedules:
schedule = Schedule.objects.create(unified_job_template=job_template, rrule=self.rrule, created_by=rando)
access = ScheduleAccess(rando)
assert access.can_change(schedule, {'rrule': self.rrule2})
def test_prompts_access_checked(self, job_template, inventory, credential, rando):
job_template.execute_role.members.add(rando)
access = ScheduleAccess(rando)
data = dict(
unified_job_template=job_template,
rrule=self.rrule,
created_by=rando,
inventory=inventory,
credentials=[credential]
)
with mock.patch('awx.main.access.JobLaunchConfigAccess.can_add') as mock_add:
mock_add.return_value = True
assert access.can_add(data)
mock_add.assert_called_once_with(data)
data.pop('credentials')
schedule = Schedule.objects.create(**data)
with mock.patch('awx.main.access.JobLaunchConfigAccess.can_change') as mock_change:
mock_change.return_value = True
assert access.can_change(schedule, {'inventory': 42})
mock_change.assert_called_once_with(schedule, {'inventory': 42})