]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/tests/test_feature_toggles.py
1 # -*- coding: utf-8 -*-
2 from __future__
import absolute_import
5 from mock
import Mock
, patch
7 from . import KVStoreMockMixin
8 from ..plugins
.feature_toggles
import FeatureToggles
, Features
11 class SettingsTest(unittest
.TestCase
, KVStoreMockMixin
):
15 cls
.CONFIG_KEY_DICT
['url_prefix'] = ''
21 # Populate real endpoint map
22 from ..controllers
import load_controllers
23 cls
.controllers
= load_controllers()
25 # Initialize FeatureToggles plugin
26 cls
.plugin
= FeatureToggles()
27 cls
.CONFIG_KEY_DICT
.update(
28 {k
['name']: k
['default'] for k
in cls
.plugin
.get_options()})
31 def test_filter_request_when_all_features_enabled(self
):
33 This test iterates over all the registered endpoints to ensure that, with default
34 feature toggles, none is disabled.
39 for controller
in self
.controllers
:
40 request
.path_info
= controller
.get_path()
42 self
.plugin
.filter_request_before_handler(request
)
43 except cherrypy
.HTTPError
:
44 self
.fail("Request filtered {} and it shouldn't".format(
47 def test_filter_request_when_some_feature_enabled(self
):
49 This test focuses on a single feature and checks whether it's actually
54 self
.plugin
.register_commands()['handle_command'](
55 self
.mgr
, 'disable', ['cephfs'])
57 with patch
.object(self
.plugin
, '_get_feature_from_request',
58 return_value
=Features
.CEPHFS
):
59 with self
.assertRaises(cherrypy
.HTTPError
):
61 self
.plugin
.filter_request_before_handler(request
)