Simplify to run Refstack in development mode
This patchs allows to run Refstack application (API + UI) using 'pecan serve' command. CONF.api.template_path and CONF.api.static_root should point to refstack-ui/app CONF.api.app_dev_mode should be set Change-Id: I9f6399a7d59cb0a4656bc8e988862d50647ed940
This commit is contained in:
parent
0e6907312c
commit
d8eccf08a1
refstack
@ -16,9 +16,12 @@
|
||||
"""Root controller."""
|
||||
|
||||
from pecan import expose
|
||||
from oslo_config import cfg
|
||||
|
||||
from refstack.api.controllers import v1
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class RootController(object):
|
||||
|
||||
@ -26,7 +29,7 @@ class RootController(object):
|
||||
|
||||
v1 = v1.V1Controller()
|
||||
|
||||
@expose('json')
|
||||
def index(self):
|
||||
"""root response."""
|
||||
return {'Root': 'OK'}
|
||||
if CONF.api.app_dev_mode:
|
||||
@expose(generic=True, template='index.html')
|
||||
def index(self):
|
||||
return dict()
|
||||
|
@ -37,18 +37,6 @@ FAKE_TESTS_RESULT = {
|
||||
}
|
||||
|
||||
|
||||
class TestRootController(api.FunctionalTest):
|
||||
"""Test case for RootController."""
|
||||
|
||||
URL = '/'
|
||||
|
||||
def test_root_controller(self):
|
||||
"""Test request to root."""
|
||||
actual_response = self.get_json(self.URL)
|
||||
expected_response = {'Root': 'OK'}
|
||||
self.assertEqual(expected_response, actual_response)
|
||||
|
||||
|
||||
class TestResultsController(api.FunctionalTest):
|
||||
"""Test case for ResultsController."""
|
||||
|
||||
|
@ -26,7 +26,6 @@ import requests
|
||||
|
||||
from refstack.api import constants as const
|
||||
from refstack.api import utils as api_utils
|
||||
from refstack.api.controllers import root
|
||||
from refstack.api.controllers import v1
|
||||
|
||||
|
||||
@ -41,10 +40,16 @@ def safe_json_dump(content):
|
||||
|
||||
class RootControllerTestCase(base.BaseTestCase):
|
||||
|
||||
def test_index(self):
|
||||
@mock.patch('pecan.expose', return_value=lambda f: f)
|
||||
def test_index(self, expose_mock):
|
||||
config = config_fixture.Config()
|
||||
CONF = self.useFixture(config).conf
|
||||
CONF.set_override('app_dev_mode', True, 'api')
|
||||
from refstack.api.controllers import root
|
||||
controller = root.RootController()
|
||||
result = controller.index()
|
||||
self.assertEqual(result, {'Root': 'OK'})
|
||||
self.assertEqual({}, result)
|
||||
expose_mock.assert_called_with(generic=True, template='index.html')
|
||||
|
||||
|
||||
class ResultsControllerTestCase(base.BaseTestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user