Terarea  2
The automation project
Loading...
Searching...
No Matches
test_actions_constants.py
Go to the documentation of this file.
1"""_summary_
2 File in charge of testing the variables class
3"""
4import os
5import sys
6
7sys.path.append(os.path.join("..", os.getcwd()))
8sys.path.append(os.getcwd())
9
10try:
11 import constants as TCONST
12except ImportError as e:
13 raise ImportError("Failed to import the unit test constants module") from e
14
15try:
16 from src.lib.actions import constants as ACONST
17except ImportError as e:
18 raise ImportError("Failed to import the src module") from e
19
20
21ERROR = TCONST.ERROR
22SUCCESS = TCONST.SUCCESS
23DEBUG = TCONST.DEBUG
24
25spaceship = ACONST._spaceship
26
27
28def test_log_types() -> None:
29 """_summary_
30 Function in charge of testing the log types.
31 """
32 assert ACONST.TYPE_UNKNOWN == "UNKNOWN LOGGING TYPE"
33 assert ACONST.TYPE_API == "API"
34 assert ACONST.TYPE_SERVICE == "SERVICE"
35 assert ACONST.TYPE_SERVICE_TRIGGER == "SERVICE TRIGGER"
36 assert ACONST.TYPE_SERVICE_ACTION == "SERVICE ACTION"
37 assert ACONST.TYPE_ACTION == "ACTION"
38 assert ACONST.TYPE_UNDEFINED == "UNDEFINED"
39 assert ACONST.TYPE_MISMATCH == "MISMATCH"
40 assert ACONST.TYPE_BEFORE_ASSIGNEMENT == "REFERENCED BEFORE ASSIGNEMENT"
41 assert ACONST.TYPE_DIV_ZERO == "DIVISION BY ZERO"
42 assert ACONST.TYPE_SYNTAX_ERROR == "SYNTAX ERROR"
43 assert ACONST.TYPE_RUNTIME_ERROR == "RUNTIME ERROR"
44 assert ACONST.TYPE_INCOMPARABLE == "INCOMPARABLE TYPES"
45 assert ACONST.TYPE_OVERFLOW == "VALUE OVERFLOW"
46 assert ACONST.TYPE_UNDERFLOW == "VALUE UNDERFLOW"
47
48
49def test_error_codes() -> None:
50 """_summary_
51 Function in charge of testing the error codes.
52 """
53 assert ACONST.CODE_UNKNOWN == -1
54 assert ACONST.CODE_INFO == 0
55 assert ACONST.CODE_SUCCESS == 1
56 assert ACONST.CODE_DEBUG == 2
57 assert ACONST.CODE_WARNING == 3
58 assert ACONST.CODE_ERROR == 4
59 assert ACONST.CODE_CRITICAL == 5
60 assert ACONST.CODE_FATAL == 6
61
62
63def test_error_level() -> None:
64 """_summary_
65 Function in charge of testing the error levels.
66 """
67 assert ACONST.LEVEL_UNKNOWN == "UNKNOWN"
68 assert ACONST.LEVEL_INFO == "INFO"
69 assert ACONST.LEVEL_SUCCESS == "SUCCESS"
70 assert ACONST.LEVEL_DEBUG == "DEBUG"
71 assert ACONST.LEVEL_WARNING == "WARNING"
72 assert ACONST.LEVEL_ERROR == "ERROR"
73 assert ACONST.LEVEL_CRITICAL == "CRITICAL"
74 assert ACONST.LEVEL_FATAL == "FATAL"
75
76
77def test_error_messages() -> None:
78 """_summary_
79 Function in charge of testing the error messages.
80 """
81 assert ACONST.MSG_UNKNOWN == "Unknown: Operation executed with unknown status."
82 assert ACONST.MSG_INFO == "Information: Operation executed without any issues."
83 assert ACONST.MSG_SUCCESS == "Success: Operation completed successfully."
84 assert ACONST.MSG_DEBUG == "Debug: Tracking detailed operational data for diagnostics."
85 assert ACONST.MSG_WARNING == "Warning: Potential issue detected. Review is recommended."
86 assert ACONST.MSG_ERROR == "Error: Operation could not be completed successfully."
87 assert ACONST.MSG_CRITICAL == "Critical: Immediate attention required to prevent severe impact."
88 assert ACONST.MSG_FATAL == "Fatal: System failure imminent. Immediate intervention necessary."
89
90
92 """_summary_
93 Function in charge of testing the error equivalence.
94 """
95 assert ACONST.LOG_EQUIVALENCE == {
96 ACONST.CODE_UNKNOWN: ACONST.LEVEL_UNKNOWN,
97 ACONST.CODE_INFO: ACONST.LEVEL_INFO,
98 ACONST.CODE_SUCCESS: ACONST.LEVEL_SUCCESS,
99 ACONST.CODE_DEBUG: ACONST.LEVEL_DEBUG,
100 ACONST.CODE_WARNING: ACONST.LEVEL_WARNING,
101 ACONST.CODE_ERROR: ACONST.LEVEL_ERROR,
102 ACONST.CODE_CRITICAL: ACONST.LEVEL_CRITICAL,
103 ACONST.CODE_FATAL: ACONST.LEVEL_FATAL,
104 }
105
106
108 """_summary_
109 Function in charge of testing the error message equivalence.
110 """
111 assert ACONST.LOG_MESSAGE_EQUIVALENCE == {
112 ACONST.CODE_UNKNOWN: ACONST.MSG_UNKNOWN,
113 ACONST.CODE_INFO: ACONST.MSG_INFO,
114 ACONST.CODE_SUCCESS: ACONST.MSG_SUCCESS,
115 ACONST.CODE_DEBUG: ACONST.MSG_DEBUG,
116 ACONST.CODE_WARNING: ACONST.MSG_WARNING,
117 ACONST.CODE_ERROR: ACONST.MSG_ERROR,
118 ACONST.CODE_CRITICAL: ACONST.MSG_CRITICAL,
119 ACONST.CODE_FATAL: ACONST.MSG_FATAL,
120 }
121
122
124 """_summary_
125 Function in charge of testing the list type equivalence.
126 """
127 assert ACONST.LIST_TYPE == [
128 ACONST.TYPE_UNKNOWN,
129 ACONST.TYPE_API,
130 ACONST.TYPE_SERVICE,
131 ACONST.TYPE_SERVICE_TRIGGER,
132 ACONST.TYPE_SERVICE_ACTION,
133 ACONST.TYPE_ACTION,
134 ACONST.TYPE_UNDEFINED,
135 ACONST.TYPE_MISMATCH,
136 ACONST.TYPE_BEFORE_ASSIGNEMENT,
137 ACONST.TYPE_DIV_ZERO,
138 ACONST.TYPE_SYNTAX_ERROR,
139 ACONST.TYPE_RUNTIME_ERROR,
140 ACONST.TYPE_INCOMPARABLE,
141 ACONST.TYPE_OVERFLOW,
142 ACONST.TYPE_UNDERFLOW,
143 ]
144
145
147 """_summary_
148 Function in charge of testing the list code equivalence.
149 """
150 assert ACONST.LIST_CODE == [
151 ACONST.CODE_UNKNOWN,
152 ACONST.CODE_INFO,
153 ACONST.CODE_SUCCESS,
154 ACONST.CODE_DEBUG,
155 ACONST.CODE_WARNING,
156 ACONST.CODE_ERROR,
157 ACONST.CODE_CRITICAL,
158 ACONST.CODE_FATAL,
159 ]
160
161
163 """_summary_
164 Function in charge of testing the list info equivalence.
165 """
166 assert ACONST.LIST_LEVEL_INFO == [
167 ACONST.LEVEL_UNKNOWN,
168 ACONST.LEVEL_INFO,
169 ACONST.LEVEL_SUCCESS,
170 ACONST.LEVEL_DEBUG,
171 ACONST.LEVEL_WARNING,
172 ACONST.LEVEL_ERROR,
173 ACONST.LEVEL_CRITICAL,
174 ACONST.LEVEL_FATAL,
175 ]
176
177
179 """_summary_
180 Function in charge of testing the list message equivalence.
181 """
182 assert ACONST.LIST_MSG == [
183 ACONST.MSG_UNKNOWN,
184 ACONST.MSG_INFO,
185 ACONST.MSG_SUCCESS,
186 ACONST.MSG_DEBUG,
187 ACONST.MSG_WARNING,
188 ACONST.MSG_ERROR,
189 ACONST.MSG_CRITICAL,
190 ACONST.MSG_FATAL,
191 ]
192
193
195 """_summary_
196 Function in charge of testing the spaceship less than operator.
197 """
198 assert spaceship(2, 3) == -1 # 2 < 3
199
200
202 """_summary_
203 Function in charge of testing the spaceship equal operator.
204 """
205 assert spaceship(5, 5) == 0 # 5 == 5
206
207
209 """_summary_
210 Function in charge of testing the spaceship greater than operator.
211 """
212 assert spaceship(7, 4) == 1 # 7 > 4
213
214
216 """_summary_
217 Function in charge of testing the spaceship negative comparison.
218 """
219 assert spaceship(-1, -2) == 1 # -1 > -2
220
221
223 """_summary_
224 Function in charge of testing the spaceship zero comparison.
225 """
226 assert spaceship(0, 0) == 0 # 0 == 0
227
228
230 """_summary_
231 Function in charge of testing the spaceship float comparison.
232 """
233 assert spaceship(2.5, 2.5) == 0 # 2.5 == 2.5
234 assert spaceship(2.5, 3.0) == -1 # 2.5 < 3.0
235 assert spaceship(3.0, 2.5) == 1 # 3.0 > 2.5
236
237
239 """_summary_
240 Function in charge of testing the spaceship string
241 """
242 assert spaceship("apple", "banana") == -1 # "apple" < "banana"
243 assert spaceship("cherry", "apple") == 1 # "cherry" > "apple"
244 assert spaceship("date", "date") == 0 # "date" == "date"