]>
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
6 from mock
import Mock
, patch
8 from unittest
.mock
import Mock
, patch
10 from . import KVStoreMockMixin
11 from ..plugins
.feature_toggles
import FeatureToggles
, Features
14 class SettingsTest(unittest
.TestCase
, KVStoreMockMixin
):
18 cls
.CONFIG_KEY_DICT
['url_prefix'] = ''
24 # Populate real endpoint map
25 from ..controllers
import load_controllers
26 cls
.controllers
= load_controllers()
28 # Initialize FeatureToggles plugin
29 cls
.plugin
= FeatureToggles()
30 cls
.CONFIG_KEY_DICT
.update(
31 {k
['name']: k
['default'] for k
in cls
.plugin
.get_options()})
34 def test_filter_request_when_all_features_enabled(self
):
36 This test iterates over all the registered endpoints to ensure that, with default
37 feature toggles, none is disabled.
42 for controller
in self
.controllers
:
43 request
.path_info
= controller
.get_path()
45 self
.plugin
.filter_request_before_handler(request
)
46 except cherrypy
.HTTPError
:
47 self
.fail("Request filtered {} and it shouldn't".format(
50 def test_filter_request_when_some_feature_enabled(self
):
52 This test focuses on a single feature and checks whether it's actually
57 self
.plugin
.register_commands()['handle_command'](
58 self
.mgr
, 'disable', ['cephfs'])
60 with patch
.object(self
.plugin
, '_get_feature_from_request',
61 return_value
=Features
.CEPHFS
):
62 with self
.assertRaises(cherrypy
.HTTPError
):
64 self
.plugin
.filter_request_before_handler(request
)