Fix unit tests error introduced by _get_session
1. What is the problem In neutron.plugins.ml2.drivers.helpers._get_session, the passed-in argument is first checked if it's a neutron.context.Context object, the argument will be directly returned if it's not a neutron Context object. In our test cases, the FakeNeutronContext does not inherit neutron Context object, so the session inside FakeNeutronContext is not returned. 2. What is the solution to the problem Make FakeNeutronContext inherit neutron Context object. A bump_revision method is also added to DotDict object since Neutron starts to call this method. 3. What the features need to be implemented to the Tricircle No new features Change-Id: Ib17eb96418088217e991e52501209e0fc1227213
This commit is contained in:
parent
d125580087
commit
7b1558e854
|
@ -34,6 +34,7 @@ from neutron_lib.plugins import directory
|
|||
|
||||
import neutron.api.v2.attributes as neutron_attributes
|
||||
import neutron.conf.common as q_config
|
||||
import neutron.context as q_context
|
||||
|
||||
from neutron.db import _utils
|
||||
from neutron.db import db_base_plugin_common
|
||||
|
@ -253,6 +254,9 @@ class DotDict(dict):
|
|||
def __copy__(self):
|
||||
return DotDict(self)
|
||||
|
||||
def bump_revision(self):
|
||||
pass
|
||||
|
||||
|
||||
class DotList(list):
|
||||
def all(self):
|
||||
|
@ -627,13 +631,12 @@ class FakeClient(object):
|
|||
pass
|
||||
|
||||
|
||||
class FakeNeutronContext(object):
|
||||
class FakeNeutronContext(q_context.Context):
|
||||
def __init__(self):
|
||||
self._session = None
|
||||
self.is_admin = True
|
||||
self.is_advsvc = False
|
||||
self.tenant_id = TEST_TENANT_ID
|
||||
self.project_id = TEST_TENANT_ID
|
||||
|
||||
@property
|
||||
def session(self):
|
||||
|
|
Loading…
Reference in New Issue