Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" Enums used for schema validation unit testing""" 

2 

3from enum import Enum 

4 

5############################################################# 

6# Test enums 

7############################################################# 

8 

9 

10class TestSubKeys(Enum): 

11 subkey1 = {"required": True, "data_type": str} 

12 subkey2 = {"required": True, "data_type": str} 

13 

14 

15class TestSubKeys2(Enum): 

16 subkey3 = {"required": True, "optional": True, "data_type": str} 

17 

18 

19class TestKeyDefaultValues(Enum): 

20 key_dv_1 = {"required": False, "data_type": str} 

21 key_dv_2 = {"required": False, "data_type": str, "default_value": "this"} 

22 key_dv_3 = {"required": False, "optional": ["test|test"], "data_type": str} 

23 key_dv_4 = {"required": False, "optional": ["test|test"], "data_type": int, "default_value": 10} 

24 key_dv_5 = {"required": False, "data_type": str, "default_value": 2039} 

25 

26 

27class TestAllowedValues(Enum): 

28 key_av_1 = {"required": False, "data_type": str, "allowed_values": {"type": "list", "criteria": ["cat", "dog"]}} 

29 key_av_2 = { 

30 "required": False, 

31 "data_type": list, 

32 "list_value_opts": {"data_type": str}, 

33 "allowed_values": {"type": "list", "criteria": ["cat", "dog"]} 

34 } 

35 unk1 = {"required": False, "data_type": str, "allowed_values": ["cat", "dog"]} 

36 unk2 = {"required": False, "data_type": str, "allowed_values": {"criteria": ["cat", "dog"]}} 

37 unk3 = {"required": False, "data_type": str, "allowed_values": {"type": "list", "criteira": ["cat", "dog"]}} 

38 key_av_3 = {"required": False, "data_type": str, "allowed_values": {"type": "list", "criteria": "dog"}} 

39 key_av_4 = {"required": False, "data_type": int, 

40 "allowed_values": {"type": "range", "criteria": {"min": 0, "max": 5}}} 

41 key_av_5 = { 

42 "required": False, 

43 "data_type": list, 

44 "list_value_opts": {"data_type": int}, 

45 "allowed_values": {"type": "range", "criteria": {"min": 0, "max": 5}} 

46 } 

47 key_av_6 = {"required": False, "data_type": int, "allowed_values": {"type": "range", "criteria": [0, 6]}} 

48 key_av_7 = {"required": False, "data_type": int, 

49 "allowed_values": {"type": "range", "criteria": {"minimum": 0, "maximum": 5}}} 

50 key_av_8 = {"required": False, "data_type": int, 

51 "allowed_values": {"type": "range", "criteria": {"min": 1, "max": -1}}} 

52 key_av_9 = {"required": False, "data_type": str, 

53 "allowed_values": {"type": "range", "criteria": {"min": 0, "max": 5}}} 

54 key_av_10 = { 

55 "required": False, 

56 "data_type": list, 

57 "list_value_opts": {"data_type": str}, 

58 "allowed_values": {"type": "range", "criteria": {"min": 0, "max": 5}} 

59 } 

60 key_av_11 = {"required": False, "data_type": str, "allowed_values": {"type": "regex", "criteria": "query(?!\.sql)"}} 

61 key_av_12 = { 

62 "required": False, 

63 "data_type": list, 

64 "list_value_opts": {"data_type": str}, 

65 "allowed_values": {"type": "regex", "criteria": "query(?!\.sql)"} 

66 } 

67 key_av_13 = {"required": False, "data_type": str, "allowed_values": {"type": "regex", "criteria": 5}} 

68 key_av_14 = {"required": False, "data_type": int, "allowed_values": {"type": "regex", "criteria": "5"}} 

69 key_av_15 = { 

70 "required": False, 

71 "data_type": list, 

72 "list_value_opts": {"data_type": int}, 

73 "allowed_values": {"type": "regex", "criteria": "5"} 

74 } 

75 

76 

77class TestDataType(Enum): 

78 key_dt_1 = {"required": False, "data_type": str} 

79 key_dt_2 = {"required": False, "data_type": list, "list_value_opts": {"data_type": int}} 

80 key_dt_3 = {"required": False, "data_type": str, "list_value_opts": {"data_type": str}} 

81 key_dt_4 = {"required": ["test|test2"], "data_type": "*"} 

82 key_dt_5 = {"required": False, "data_type": list, "list_value_opts": {"data_type": "*"}} 

83 key_dt_6 = {"required": False, "optional": True} 

84 key_dt_7 = {"required": False, "optional": True, "data_type": list} 

85 

86 

87class TestListValueOpts(Enum): 

88 key_lvo_1 = {"required": False, "data_type": list, "list_value_opts": {"data_type": str, "allow_duplicates": False}} 

89 key_lvo_2 = {"required": False, "data_type": list, "list_value_opts": {"data_type": str}} 

90 key_lvo_3 = {"required": False, "data_type": list, "list_value_opts": {"data_type": str, "allow_duplicates": True}} 

91 key_lvo_4 = {"required": False, "data_type": list, "list_value_opts": {"data_type": str, "allow_empty_list": False}} 

92 key_lvo_5 = {"required": False, "data_type": list, "list_value_opts": {"data_type": str}} 

93 key_lvo_6 = {"required": False, "data_type": list, "list_value_opts": {"data_type": str, "allow_empty_list": True}} 

94 

95 

96class TestOther(Enum): 

97 key_o_1 = {"required": True, "data_type": str} 

98 key_o_2 = {"required": ["test|test"], "data_type": str} 

99 key_o_3 = {"required": ["test|test2"], "data_type": "*"} 

100 key_o_4 = {"required": False, "data_type": dict, "keys": TestSubKeys} 

101 key_o_5 = {"required": False, "optional": ["test|test2"], "data_type": str} 

102 

103 

104class TestTypeMapping(Enum): 

105 test_key_default_values = TestKeyDefaultValues 

106 test_allowed_values = TestAllowedValues 

107 test_data_type = TestDataType 

108 test_list_value_opts = TestListValueOpts 

109 test_other = TestOther 

110 

111 

112class TestEndpointAccessKeys(Enum): 

113 type = { 

114 "required": True, 

115 "data_type": str, 

116 "allowed_values": { 

117 "type": "list", 

118 "criteria": [ 

119 "test_key_default_values", 

120 "test_allowed_values", 

121 "test_data_type", 

122 "test_list_value_opts", 

123 "test_other" 

124 ] 

125 } 

126 } 

127 test_details = {"required": True, "data_type": dict, "key_map": TestTypeMapping} 

128 

129 

130class TestType1Keys(Enum): 

131 subkey4 = {"required": True, "data_type": str} 

132 subkey5 = {"required": True, "data_type": str} 

133 

134 

135class TestType2Keys(Enum): 

136 subkey6 = {"required": True, "data_type": str} 

137 subkey7 = {"required": True, "data_type": str} 

138 

139 

140class TestTypeMapping(Enum): 

141 testtype1 = TestType1Keys 

142 testtype2 = TestType2Keys 

143 

144 

145class TestEndpointMapFromKeys(Enum): 

146 type = {"required": True, "data_type": str, "allowed_values": {"type": "list", "criteria": ["testtype1", "testtype2"]}} 

147 opts = {"required": True, "data_type": dict, "key_map": TestTypeMapping} 

148 

149 

150class TestEndpointOptsKeys(Enum): 

151 key10 = {"required": False, "data_type": dict, "keys": TestEndpointMapFromKeys} 

152 

153############################################################# 

154#############################################################