Add _choices endpoint tests for all apps

This commit is contained in:
Jeremy Stretch
2020-01-14 15:50:32 -05:00
parent 8296fd026c
commit a1f62f63f7
11 changed files with 214 additions and 7 deletions

View File

@@ -1,3 +1,6 @@
from utilities.forms import unpack_grouped_choices
class ChoiceSetMeta(type):
"""
Metaclass for ChoiceSet
@@ -20,6 +23,11 @@ class ChoiceSet(metaclass=ChoiceSetMeta):
def values(cls):
return [c[0] for c in cls.CHOICES]
@classmethod
def as_dict(cls):
# Unpack grouped choices before casting as a dict
return dict(unpack_grouped_choices(cls.CHOICES))
@classmethod
def slug_to_id(cls, slug):
"""