Merge pull request #1593 from AlanCoding/fix_processed

Fix bug with non-event model
This commit is contained in:
Alan Rominger 2018-03-16 14:53:05 -04:00 committed by GitHub
commit 1413659f5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -930,7 +930,11 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
'''
if self.status in ACTIVE_STATES:
return False # tally of events is only available at end of run
return self.emitted_events == self.get_event_queryset().count()
try:
event_qs = self.get_event_queryset()
except NotImplementedError:
return True # Model without events, such as WFJT
return self.emitted_events == event_qs.count()
def result_stdout_raw_handle(self, enforce_max_bytes=True):
"""

View File

@ -141,3 +141,16 @@ class TestMetaVars:
)
data = job.awx_meta_vars()
assert data['awx_schedule_id'] == schedule.pk
@pytest.mark.django_db
def test_event_processing_not_finished():
job = Job.objects.create(emitted_events=2, status='finished')
job.event_class.objects.create(job=job)
assert not job.event_processing_finished
@pytest.mark.django_db
def test_event_model_undefined():
wj = WorkflowJob.objects.create(name='foobar', status='finished')
assert wj.event_processing_finished