fix bug with non-event model

This commit is contained in:
AlanCoding 2018-03-16 14:27:36 -04:00
parent 85a95c8cb8
commit bbbb7def0a
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B
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