mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Enable plugins to define user preferences
This commit is contained in:
20
netbox/extras/tests/dummy_plugin/preferences.py
Normal file
20
netbox/extras/tests/dummy_plugin/preferences.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from users.preferences import UserPreference
|
||||
|
||||
|
||||
preferences = {
|
||||
'pref1': UserPreference(
|
||||
label='First preference',
|
||||
choices=(
|
||||
('foo', 'Foo'),
|
||||
('bar', 'Bar'),
|
||||
)
|
||||
),
|
||||
'pref2': UserPreference(
|
||||
label='Second preference',
|
||||
choices=(
|
||||
('a', 'A'),
|
||||
('b', 'B'),
|
||||
('c', 'C'),
|
||||
)
|
||||
),
|
||||
}
|
@@ -74,6 +74,15 @@ class PluginTest(TestCase):
|
||||
|
||||
self.assertIn(SiteContent, registry['plugin_template_extensions']['dcim.site'])
|
||||
|
||||
def test_user_preferences(self):
|
||||
"""
|
||||
Check that plugin UserPreferences are registered.
|
||||
"""
|
||||
self.assertIn('dummy_plugin', registry['plugin_preferences'])
|
||||
user_preferences = registry['plugin_preferences']['dummy_plugin']
|
||||
self.assertEqual(type(user_preferences), dict)
|
||||
self.assertEqual(list(user_preferences.keys()), ['pref1', 'pref2'])
|
||||
|
||||
def test_middleware(self):
|
||||
"""
|
||||
Check that plugin middleware is registered.
|
||||
|
Reference in New Issue
Block a user