|
3 | 3 | from demisto_sdk.commands.content_graph.objects.agentix_action import AgentixAction |
4 | 4 | from demisto_sdk.commands.content_graph.objects.agentix_agent import AgentixAgent |
5 | 5 | from demisto_sdk.commands.content_graph.objects.script import Script |
| 6 | +from demisto_sdk.commands.validate.tests.test_tools import create_agentix_agent_object |
6 | 7 | from demisto_sdk.commands.validate.validators.AG_validators.AG100_is_forbidden_content_item import ( |
7 | 8 | IsForbiddenContentItemValidator, |
8 | 9 | ) |
9 | 10 | from demisto_sdk.commands.validate.validators.AG_validators.AG101_is_correct_mp import ( |
10 | 11 | IsCorrectMPValidator, |
11 | 12 | ) |
| 13 | +from demisto_sdk.commands.validate.validators.AG_validators.AG104_is_valid_rgb_color import ( |
| 14 | + IsValidColorValidator, |
| 15 | +) |
12 | 16 |
|
13 | 17 |
|
14 | 18 | def test_is_forbidden_content_item(): |
@@ -215,3 +219,51 @@ def test_is_correct_marketplace(): |
215 | 219 | assert results[0].message == ( |
216 | 220 | "The following Agentix related content item 'test' should have only marketplace 'platform'." |
217 | 221 | ) |
| 222 | + |
| 223 | + |
| 224 | +def test_is_valid_color(): |
| 225 | + """ |
| 226 | + Given: |
| 227 | + - Two AgentixAgent items, one with a valid color and one with an invalid color. |
| 228 | +
|
| 229 | + When: |
| 230 | + - Calling the IsValidColorValidator obtain_invalid_content_items function. |
| 231 | +
|
| 232 | + Then: |
| 233 | + - Make sure one failure is returned for the invalid color and the error message is correct. |
| 234 | + """ |
| 235 | + content_items = [ |
| 236 | + create_agentix_agent_object( |
| 237 | + paths=["color", "display"], |
| 238 | + values=["#FF0000", "Valid Color Agent"], |
| 239 | + ), |
| 240 | + create_agentix_agent_object( |
| 241 | + paths=["color", "display"], |
| 242 | + values=["invalid_color", "Invalid Color Agent"], |
| 243 | + ), |
| 244 | + create_agentix_agent_object( |
| 245 | + paths=["color", "display"], |
| 246 | + values=["#12345G", "Invalid Hex Agent"], |
| 247 | + ), |
| 248 | + create_agentix_agent_object( |
| 249 | + paths=["color", "display"], |
| 250 | + values=["#FFF", "Short Hex Agent"], |
| 251 | + ), |
| 252 | + ] |
| 253 | + |
| 254 | + results = IsValidColorValidator().obtain_invalid_content_items(content_items) |
| 255 | + |
| 256 | + assert len(results) == 3 |
| 257 | + error_messages = [result.message for result in results] |
| 258 | + assert ( |
| 259 | + "The Agentix-agent 'Invalid Color Agent' color 'invalid_color' is not a valid RGB hex color.\n" |
| 260 | + "Please make sure that the color is a valid 6-digit hex color string, starting with '#'. For example: '#FFFFFF'." |
| 261 | + ) in error_messages |
| 262 | + assert ( |
| 263 | + "The Agentix-agent 'Invalid Hex Agent' color '#12345G' is not a valid RGB hex color.\n" |
| 264 | + "Please make sure that the color is a valid 6-digit hex color string, starting with '#'. For example: '#FFFFFF'." |
| 265 | + ) in error_messages |
| 266 | + assert ( |
| 267 | + "The Agentix-agent 'Short Hex Agent' color '#FFF' is not a valid RGB hex color.\n" |
| 268 | + "Please make sure that the color is a valid 6-digit hex color string, starting with '#'. For example: '#FFFFFF'." |
| 269 | + ) in error_messages |
0 commit comments