Added 'goal' ObjectField for Strategy object

In this changeset, I added the "goal" ObjectField which can
either be loaded by setting the new "eager" parameter as True or
not loaded (as before) by setting it to False.
The advantage of introducing this eager parameter is that this way,
we can reduce to a minimum the overhead of DB queries whenever the
related goal is not actually needed.

Partially-Implements: blueprint watcher-versioned-objects
Change-Id: I103c9ed161d2cedf7b43c55f9e095ef66bf44dea
This commit is contained in:
Vincent Françoise
2016-09-23 16:46:41 +02:00
parent fc31dae7f2
commit f54aca70cc
9 changed files with 255 additions and 132 deletions

View File

@@ -199,7 +199,7 @@ def create_test_scoring_engine(**kwargs):
def get_test_strategy(**kwargs):
return {
strategy_data = {
'id': kwargs.get('id', 1),
'uuid': kwargs.get('uuid', 'cb3d0b58-4415-4d90-b75b-1e96878730e3'),
'name': kwargs.get('name', 'TEST'),
@@ -208,9 +208,16 @@ def get_test_strategy(**kwargs):
'created_at': kwargs.get('created_at'),
'updated_at': kwargs.get('updated_at'),
'deleted_at': kwargs.get('deleted_at'),
'parameters_spec': kwargs.get('parameters_spec', {})
'parameters_spec': kwargs.get('parameters_spec', {}),
}
# goal ObjectField doesn't allow None nor dict, so if we want to simulate a
# non-eager object loading, the field should not be referenced at all.
if kwargs.get('goal'):
strategy_data['goal'] = kwargs.get('goal')
return strategy_data
def get_test_service(**kwargs):
return {