MCPcopy
hub / github.com/tanelpoder/0xtools / validate_table_columns

Function validate_table_columns

xtop/tests/test_tui_basic.py:159–192  ·  view source on GitHub ↗

Validate that expected columns are present in the table

(app, expected_columns)

Source from the content-addressed store, hash-verified

157
158
159def validate_table_columns(app, expected_columns):
160 """Validate that expected columns are present in the table"""
161 columns, _ = get_table_data(app)
162
163 # Convert to lowercase for comparison (already stripped in get_table_data)
164 columns_lower = [col.lower() for col in columns]
165
166 missing_columns = []
167 for expected in expected_columns:
168 expected_lower = expected.lower().strip()
169
170 # Check for exact match or partial match
171 # Be very flexible - username might appear as 'user', 'username', 'usr', etc.
172 found = False
173 for col in columns_lower:
174 # Check various possibilities
175 if (expected_lower == col or # Exact match
176 expected_lower in col or # Expected is substring of column
177 col in expected_lower or # Column is substring of expected
178 (expected_lower[:3] in col and len(expected_lower) > 3) or # First 3 chars match
179 (col[:3] in expected_lower and len(col) > 3)): # First 3 chars of col in expected
180 found = True
181 break
182
183 if not found:
184 missing_columns.append(expected)
185
186 if missing_columns:
187 error_msg = f"Validation error: Columns {missing_columns} not found. Available columns: {columns}"
188 print(error_msg)
189 return False
190
191 print(f"✓ Validated columns: {expected_columns} found in {columns}")
192 return True
193
194
195# Main test functions

Callers 1

validate_resultMethod · 0.90

Calls 1

get_table_dataFunction · 0.70

Tested by

no test coverage detected