forked from alshurov13/allure-testops-mcp-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsv_parser.py
More file actions
35 lines (25 loc) · 1014 Bytes
/
csv_parser.py
File metadata and controls
35 lines (25 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
CSV Parser for Test Cases
Parses CSV content and converts it to test case objects
"""
import csv
from io import StringIO
from typing import List, Dict, Any
def parse_test_cases_from_csv(csv_content: str) -> List[Dict[str, Any]]:
"""Parse CSV content and return list of test case dictionaries"""
reader = csv.DictReader(StringIO(csv_content))
test_cases = []
for record in reader:
# Skip empty lines
if not record.get('name'):
continue
test_case = {
'name': record.get('name', '').strip(),
'description': record.get('description', '').strip() or '',
'status': record.get('status', '').strip() or 'draft',
}
# Handle automated field - can be 'true', '1', 'True', etc.
automated_str = record.get('automated', '').strip().lower()
test_case['automated'] = automated_str in ('true', '1', 'yes')
test_cases.append(test_case)
return test_cases