Пример #1
0
 def update_model(self, pk, _attempt=0, **updates):
     return update_model(self.model, pk, _attempt=0, **updates)
Пример #2
0
 def update_model(self, pk, _attempt=0, **updates):
     return update_model(self.model, pk, _attempt=0, _max_attempts=self.update_attempts, **updates)
Пример #3
0
def test_deleted_job(normal_job):
    job_pk = normal_job.pk
    normal_job.delete()
    assert update_model(Job, job_pk) is None
Пример #4
0
def test_unknown_exception(normal_job, mocker):
    mocker.patch.object(Job.objects, 'get', side_effect=NewException)
    mocker.patch('awx.main.utils.update_model.time.sleep')
    with pytest.raises(NewException):
        update_model(Job, normal_job.pk)
Пример #5
0
def test_exception(normal_job, mocker):
    mocker.patch.object(Job.objects, 'get', side_effect=DatabaseError)
    mocker.patch('awx.main.utils.update_model.time.sleep')
    with pytest.raises(DatabaseError):
        update_model(Job, normal_job.pk)
Пример #6
0
def test_normal_get(normal_job):
    mod_job = Job.objects.get(pk=normal_job.id)
    mod_job.job_explanation = 'foobar'
    mod_job.save(update_fields=['job_explanation'])
    new_job = update_model(Job, normal_job.pk)
    assert new_job.job_explanation == 'foobar'