From 3e1dfae164dabcfa750b6f45cb4fceba140db186 Mon Sep 17 00:00:00 2001 From: Greg Hill Date: Tue, 17 Nov 2015 08:32:32 -0600 Subject: [PATCH] Add public property from storage to flowdetail.meta Sometimes you need to access the metadata from listeners and currently that requires a private property access. Change-Id: Ib4f15650b15dfe8a04dbb690607d515663371d90 Fixes: #1511086 --- taskflow/storage.py | 5 +++++ taskflow/tests/unit/test_storage.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/taskflow/storage.py b/taskflow/storage.py index f6769369e..46936ebc5 100644 --- a/taskflow/storage.py +++ b/taskflow/storage.py @@ -301,6 +301,11 @@ class Storage(object): # This never changes (so no read locking needed). return self._flowdetail.uuid + @property + def flow_meta(self): + """The flow detail metadata this storage unit is associated with.""" + return self._flowdetail.meta + @property def backend(self): """The backend this storage unit is associated with.""" diff --git a/taskflow/tests/unit/test_storage.py b/taskflow/tests/unit/test_storage.py index 53ca21064..dae5a22c0 100644 --- a/taskflow/tests/unit/test_storage.py +++ b/taskflow/tests/unit/test_storage.py @@ -60,11 +60,13 @@ class StorageTestMixin(object): s.ensure_atom(test_utils.NoopTask('my_task')) self.assertTrue(uuidutils.is_uuid_like(s.get_atom_uuid('my_task'))) - def test_flow_name_and_uuid(self): + def test_flow_name_uuid_and_meta(self): flow_detail = models.FlowDetail(name='test-fd', uuid='aaaa') + flow_detail.meta = {'a': 1} s = self._get_storage(flow_detail) self.assertEqual('test-fd', s.flow_name) self.assertEqual('aaaa', s.flow_uuid) + self.assertEqual({'a': 1}, s.flow_meta) def test_ensure_task(self): s = self._get_storage()