Skip to content
Snippets Groups Projects
Commit d05db5bd authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-917: adapted and fixed various tests now that we reverted to a single...

TMSS-917: adapted and fixed various tests now that we reverted to a single parent TaskBlueprint for a Subtask.
parent 75cc671a
No related branches found
No related tags found
2 merge requests!634WIP: COBALT commissioning delta,!540TMSS-917: primary subtask
......@@ -207,43 +207,43 @@ class TMSSPGListener(PostgresListener):
subtask = Subtask.objects.get(id=subtask_id)
# check if task is new or changed... If so, send event.
for task_blueprint in subtask.task_blueprints.all():
task_id = task_blueprint.id
task_cached_properties = {'status': task_blueprint.status,
'start_time': task_blueprint.start_time,
'stop_time': task_blueprint.stop_time }
if task_id not in self._task_cache or self._task_cache[task_id][1] != task_cached_properties:
# send generic updated event
self.onTaskBlueprintUpdated( {'id': task_id})
# only send status updated event when the status changed
if task_cached_properties['status'] != self._task_cache.get(task_id, (None, {}))[1].get('status'):
self._sendNotification(TMSS_TASKBLUEPRINT_STATUS_EVENT_PREFIX+'.'+task_cached_properties['status'].capitalize(),
{'id': task_id, 'status': task_cached_properties['status']})
# update cache for this task
self._task_cache[task_id] = (datetime.utcnow(), task_cached_properties)
# check if scheduling_unit status is new or changed... If so, send event.
scheduling_unit = task_blueprint.scheduling_unit_blueprint
scheduling_unit_id = scheduling_unit.id
scheduling_unit_cached_properties = {'status': scheduling_unit.status,
'start_time': scheduling_unit.start_time,
'stop_time': scheduling_unit.stop_time }
if scheduling_unit_id not in self._scheduling_unit_cache or self._scheduling_unit_cache[scheduling_unit_id][1] != scheduling_unit_cached_properties:
# send generic updated event
self.onSchedulingUnitBlueprintUpdated( {'id': scheduling_unit_id})
# only send status updated event when the status changed
if scheduling_unit_cached_properties['status'] != self._scheduling_unit_cache.get(scheduling_unit_id, (None, {}))[1].get('status'):
self._sendNotification(TMSS_SCHEDULINGUNITBLUEPRINT_STATUS_EVENT_PREFIX+'.'+scheduling_unit_cached_properties['status'].capitalize(),
{'id': scheduling_unit_id, 'status': scheduling_unit_cached_properties['status']})
# update cache for this task
self._scheduling_unit_cache[scheduling_unit_id] = (datetime.utcnow(), scheduling_unit_cached_properties)
task_blueprint = subtask.task_blueprint
task_id = subtask.task_blueprint.id
task_cached_properties = {'status': task_blueprint.status,
'start_time': task_blueprint.start_time,
'stop_time': task_blueprint.stop_time }
if task_id not in self._task_cache or self._task_cache[task_id][1] != task_cached_properties:
# send generic updated event
self.onTaskBlueprintUpdated( {'id': task_id})
# only send status updated event when the status changed
if task_cached_properties['status'] != self._task_cache.get(task_id, (None, {}))[1].get('status'):
self._sendNotification(TMSS_TASKBLUEPRINT_STATUS_EVENT_PREFIX+'.'+task_cached_properties['status'].capitalize(),
{'id': task_id, 'status': task_cached_properties['status']})
# update cache for this task
self._task_cache[task_id] = (datetime.utcnow(), task_cached_properties)
# check if scheduling_unit status is new or changed... If so, send event.
scheduling_unit = task_blueprint.scheduling_unit_blueprint
scheduling_unit_id = scheduling_unit.id
scheduling_unit_cached_properties = {'status': scheduling_unit.status,
'start_time': scheduling_unit.start_time,
'stop_time': scheduling_unit.stop_time }
if scheduling_unit_id not in self._scheduling_unit_cache or self._scheduling_unit_cache[scheduling_unit_id][1] != scheduling_unit_cached_properties:
# send generic updated event
self.onSchedulingUnitBlueprintUpdated( {'id': scheduling_unit_id})
# only send status updated event when the status changed
if scheduling_unit_cached_properties['status'] != self._scheduling_unit_cache.get(scheduling_unit_id, (None, {}))[1].get('status'):
self._sendNotification(TMSS_SCHEDULINGUNITBLUEPRINT_STATUS_EVENT_PREFIX+'.'+scheduling_unit_cached_properties['status'].capitalize(),
{'id': scheduling_unit_id, 'status': scheduling_unit_cached_properties['status']})
# update cache for this task
self._scheduling_unit_cache[scheduling_unit_id] = (datetime.utcnow(), scheduling_unit_cached_properties)
except Subtask.DoesNotExist:
pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment