|
58 | 58 |
|
59 | 59 |
|
60 | 60 | def get_random_text(length: int = 10): |
61 | | - return "".join(random.choice(ascii_lowercase) for i in range(length)) |
| 61 | + return "".join(random.choice(ascii_lowercase) for _ in range(length)) |
62 | 62 |
|
63 | 63 |
|
64 | | -def wait_for_condition(interval: int, timeout: int, condition: Callable): |
| 64 | +def wait_for_condition(interval: int, timeout: int, condition: Callable, *args): |
65 | 65 | start_time = time.time() |
66 | 66 | while True: |
67 | | - if condition(): |
| 67 | + result = condition(*args) |
| 68 | + |
| 69 | + if result: |
68 | 70 | break |
69 | 71 |
|
70 | 72 | if time.time() - start_time > timeout: |
@@ -213,3 +215,26 @@ def assert_help_actions_list(expected_actions, help_output): |
213 | 215 | output_actions = re.findall(r"│\s(\S+(?:,\s)?\S+)\s*│", help_output) |
214 | 216 | for expected_action in expected_actions: |
215 | 217 | assert expected_action in output_actions |
| 218 | + |
| 219 | + |
| 220 | +def view_command_attribute( |
| 221 | + command: str, action: str, item_id: str, attribute: str |
| 222 | +) -> str: |
| 223 | + return exec_test_command( |
| 224 | + BASE_CMDS[command] |
| 225 | + + [ |
| 226 | + action, |
| 227 | + item_id, |
| 228 | + "--text", |
| 229 | + "--no-header", |
| 230 | + "--format", |
| 231 | + attribute, |
| 232 | + ] |
| 233 | + ) |
| 234 | + |
| 235 | + |
| 236 | +def check_attribute_value( |
| 237 | + command: str, action: str, item_id: str, attribute: str, expected_val: str |
| 238 | +) -> bool: |
| 239 | + result = view_command_attribute(command, action, item_id, attribute) |
| 240 | + return expected_val in result |
0 commit comments