mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Drop as_dict() method from ChoiceSet
This commit is contained in:
parent
124302908a
commit
1902ecb8ca
@ -167,8 +167,8 @@ class Report(object):
|
||||
"""
|
||||
Log a message from a test method. Do not call this method directly; use one of the log_* wrappers below.
|
||||
"""
|
||||
if level not in LogLevelChoices.as_dict():
|
||||
raise Exception("Unknown logging level: {}".format(level))
|
||||
if level not in LogLevelChoices.values():
|
||||
raise Exception(f"Unknown logging level: {level}")
|
||||
self._results[self.active_test]['log'].append((
|
||||
timezone.now().isoformat(),
|
||||
level,
|
||||
|
@ -12,6 +12,6 @@ def log_level(level):
|
||||
Display a label indicating a syslog severity (e.g. info, warning, etc.).
|
||||
"""
|
||||
return {
|
||||
'name': LogLevelChoices.as_dict()[level],
|
||||
'name': dict(LogLevelChoices)[level],
|
||||
'class': LogLevelChoices.colors.get(level)
|
||||
}
|
||||
|
@ -50,11 +50,6 @@ class ChoiceSet(metaclass=ChoiceSetMeta):
|
||||
def values(cls):
|
||||
return [c[0] for c in unpack_grouped_choices(cls._choices)]
|
||||
|
||||
@classmethod
|
||||
def as_dict(cls):
|
||||
# Unpack grouped choices before casting as a dict
|
||||
return dict(unpack_grouped_choices(cls._choices))
|
||||
|
||||
|
||||
def unpack_grouped_choices(choices):
|
||||
"""
|
||||
|
@ -30,8 +30,3 @@ class ChoiceSetTestCase(TestCase):
|
||||
|
||||
def test_values(self):
|
||||
self.assertListEqual(ExampleChoices.values(), ['a', 'b', 'c', 1, 2, 3])
|
||||
|
||||
def test_as_dict(self):
|
||||
self.assertEqual(ExampleChoices.as_dict(), {
|
||||
'a': 'A', 'b': 'B', 'c': 'C', 1: 'One', 2: 'Two', 3: 'Three'
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user