Use parameters in config file for trust test
``create_ctx_from_trust`` creates a context using project_id and user_id that are set to blazar configuration file, but the test is fixed to use "admin", which can cause unpredictable unit test error on developer's local environment. This patch fixes the problem. Change-Id: Ied2451d8821dc0ac3f59fe838efec01453839909 Closes-Bug: #1777399
This commit is contained in:
parent
29ce880caa
commit
36259acf75
|
@ -15,12 +15,17 @@
|
|||
|
||||
import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as conf_fixture
|
||||
|
||||
from blazar import context
|
||||
from blazar import tests
|
||||
from blazar.utils.openstack import base
|
||||
from blazar.utils.openstack import keystone
|
||||
from blazar.utils import trusts
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class TestTrusts(tests.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -34,6 +39,8 @@ class TestTrusts(tests.TestCase):
|
|||
self.patch(self.context, 'current')
|
||||
self.patch(self.base, 'url_for').return_value = 'http://www.foo.fake'
|
||||
|
||||
self.cfg = self.useFixture(conf_fixture.Config(CONF))
|
||||
|
||||
def test_create_trust(self):
|
||||
correct_trust = self.client().trusts.create()
|
||||
|
||||
|
@ -49,6 +56,8 @@ class TestTrusts(tests.TestCase):
|
|||
self.client.assert_called_once_with(trust_id='1')
|
||||
|
||||
def test_create_ctx_from_trust(self):
|
||||
self.cfg.config(os_admin_project_name='admin')
|
||||
self.cfg.config(os_admin_username='admin')
|
||||
fake_item = self.client().service_catalog.catalog.__getitem__()
|
||||
fake_ctx_dict = {'_BaseContext__values': {
|
||||
'auth_token': self.client().auth_token,
|
||||
|
|
Loading…
Reference in New Issue