Coverage for audoma/plumbing.py: 50%

1 from typing import (

2 List,

3 Tuple,

4 Type,

5 Union,

6)

7

8 from drf_spectacular.drainage import cache

9 from rest_framework import (

10 generics,

11 mixins,

12 serializers,

13 views,

14 viewsets,

15)

16

17 from audoma.drf import (

18 generics as audoma_generics,

19 mixins as audoma_mixins,

20 serializers as audoma_serializers,

21 viewsets as audoma_viewsets,

22)

23

24

25@cache

26 def get_lib_doc_excludes_audoma() -> List[Type]:

27

28 return [

29 views.APIView,

30 *[

31 getattr(serializers, c)

32 for c in dir(serializers)

33 if c.endswith("Serializer")

34 ],

35 *[getattr(viewsets, c) for c in dir(viewsets) if c.endswith("ViewSet")],

36 *[getattr(generics, c) for c in dir(generics) if c.endswith("APIView")],

37 *[getattr(mixins, c) for c in dir(mixins) if c.endswith("Mixin")],

38 *[

39 getattr(audoma_viewsets, c)

40 for c in dir(audoma_viewsets)

41 if c.endswith("ViewSet")

42 ],

43 *[getattr(audoma_mixins, c) for c in dir(audoma_mixins) if c.endswith("Mixin")],

44 *[

45 getattr(audoma_serializers, c)

46 for c in dir(audoma_serializers)

47 if c.endswith("Serializer")

48 ],

49 *[

50 getattr(audoma_generics, c)

51 for c in dir(audoma_generics)

52 if c.endswith("APIView")

53 ],

54 ]

55

56

57 def create_choices_enum_description(choices: Union[dict, List[Tuple]], field_name):

58

59 if not isinstance(choices, dict):

60 choices = dict(choices)

61

62 description = f"Filter by {field_name} \n"

63 for key, val in choices.items():

64 description += f" * `{key}` - {val}\n"

65 return description