mirror of
https://github.com/ceph/ceph
synced 2025-01-24 03:53:54 +00:00
b0bdbc3414
this change partially reverts #34139 using relative import helps with readability and ease the pain to write down the full parent module name in #34139, all relative imports were replaced with full path, because we were using following code to verify if the code is python3 compatible: ``` mod_spec = importlib.util.spec_from_file_location(mod_name, path) mod = importlib.util.module_from_spec(mod_spec) mod_spec.loader.exec_module(mod) ``` but this does not work with submodule which can import using relative import without specifying the name of the package and its parent module. Signed-off-by: Kefu Chai <kchai@redhat.com>
66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from .helper import DashboardTestCase, JList, JObj, JAny
|
|
|
|
|
|
class SettingsTest(DashboardTestCase):
|
|
def setUp(self):
|
|
super(SettingsTest, self).setUp()
|
|
self.settings = self._get('/api/settings')
|
|
|
|
def tearDown(self):
|
|
self._put(
|
|
'/api/settings',
|
|
{setting['name']: setting['value']
|
|
for setting in self.settings})
|
|
|
|
def test_list_settings(self):
|
|
settings = self._get('/api/settings')
|
|
self.assertGreater(len(settings), 10)
|
|
self.assertSchema(
|
|
settings,
|
|
JList(
|
|
JObj({
|
|
'default': JAny(none=False),
|
|
'name': str,
|
|
'type': str,
|
|
'value': JAny(none=False)
|
|
})))
|
|
self.assertStatus(200)
|
|
|
|
def test_get_setting(self):
|
|
setting = self._get('/api/settings/rgw-api-access-key')
|
|
self.assertSchema(
|
|
setting,
|
|
JObj({
|
|
'default': JAny(none=False),
|
|
'name': str,
|
|
'type': str,
|
|
'value': JAny(none=False)
|
|
}))
|
|
self.assertStatus(200)
|
|
|
|
def test_set_setting(self):
|
|
self._put('/api/settings/rgw-api-access-key', {'value': 'foo'})
|
|
self.assertStatus(200)
|
|
|
|
value = self._get('/api/settings/rgw-api-access-key')['value']
|
|
self.assertEqual('foo', value)
|
|
|
|
def test_bulk_set(self):
|
|
self._put('/api/settings', {
|
|
'RGW_API_HOST': 'somehost',
|
|
'RGW_API_PORT': 7777,
|
|
})
|
|
self.assertStatus(200)
|
|
|
|
host = self._get('/api/settings/rgw-api-host')['value']
|
|
self.assertStatus(200)
|
|
self.assertEqual('somehost', host)
|
|
|
|
port = self._get('/api/settings/rgw-api-port')['value']
|
|
self.assertStatus(200)
|
|
self.assertEqual(7777, port)
|