7
7
from modules .testrail_integration import testrail_init
8
8
9
9
# Set up logging
10
- logging .basicConfig (
11
- level = logging .INFO , format = "%(asctime)s - %(levelname)s - %(message)s"
12
- )
10
+ logging .basicConfig (level = logging .INFO , format = "%(message)s" )
13
11
14
12
# Load env file from project root
15
13
script_dir = os .path .dirname (__file__ )
16
- project_root = os .path .abspath (os .path .join (script_dir , ".." ))
14
+ project_root = os .path .abspath (os .path .join (script_dir , ".." , ".." ))
17
15
env_file_path = os .path .join (project_root , "testrail_credentials.env" )
18
16
load_dotenv (dotenv_path = env_file_path )
19
17
20
18
# TestRail project ID (Fx Desktop)
21
19
PROJECT_ID = 17
22
20
23
- # Specific suites to process
24
- SUITES = [
25
- ("18215" , "Address Bar and Search" ),
26
- ("1731" , "Audio/Video" ),
27
- ("2525" , "Bookmarks and History" ),
28
- ("29219" , "Downloads" ),
29
- ("5259" , "Drag and Drop" ),
30
- ("2085" , "Find Toolbar" ),
31
- ("2054" , "Form Autofill" ),
32
- ("498" , "Geolocation" ),
33
- ("22801" , "Language Packs" ),
34
- ("85" , "Menus" ),
35
- ("6066" , "Networking" ),
36
- ("1907" , "Notifications" ),
37
- ("65" , "PDF Viewer" ),
38
- ("43517" , "Password Manager" ),
39
- ("5403" , "Pocket" ),
40
- ("2241" , "Preferences" ),
41
- ("2119" , "Profile" ),
42
- ("73" , "Printing UI" ),
43
- ("2126" , "Reader View" ),
44
- ("102" , "Scrolling" ),
45
- ("5833" , "Security and Privacy" ),
46
- ("2130" , "Sync & Firefox Account" ),
47
- ("2103" , "Tabs" ),
48
- ("1997" , "Theme and Toolbar" ),
49
- ]
50
-
51
21
# Automation status values
52
22
AUTOMATION_STATUS = {"UNTRIAGED" : 1 , "SUITABLE" : 2 , "NOT_SUITABLE" : 3 , "COMPLETED" : 4 }
53
23
58
28
COVERAGE_NAMES = {1 : "None" , 2 : "Partial" , 3 : "Full" }
59
29
60
30
31
+ def get_all_suites (tr , project_id ):
32
+ """Get all suites from the project"""
33
+ suites = tr .client .send_get (f"get_suites/{ project_id } " )
34
+ logging .info (f"Found { len (suites )} suites in project { project_id } " )
35
+ return suites
36
+
37
+
61
38
def get_all_test_cases (tr , project_id , suite_id ):
62
39
"""Fetch all test cases from a suite by handling pagination."""
63
40
all_cases = []
@@ -83,11 +60,10 @@ def get_all_test_cases(tr, project_id, suite_id):
83
60
return all_cases
84
61
85
62
86
- def set_untriaged_suitable_to_null_coverage (
87
- tr , project_id , dry_run = True , batch_size = 25
88
- ):
63
+ def update_coverage_to_none (tr , project_id , dry_run = True , batch_size = 25 ):
89
64
"""
90
- Set automation coverage to None for test cases that have automation status of Untriaged or Suitable
65
+ Set automation coverage to None for all test cases that have automation status of
66
+ Untriaged, Suitable, or Not Suitable, regardless of their current coverage value
91
67
"""
92
68
start_time = time .time ()
93
69
try :
@@ -97,10 +73,14 @@ def set_untriaged_suitable_to_null_coverage(
97
73
updated_count = 0
98
74
changed_case_ids = [] # Track all case IDs that will be changed
99
75
100
- # Process each specified suite
101
- total_suites = len (SUITES )
102
- for index , (suite_id , suite_name ) in enumerate (SUITES , 1 ):
103
- # Show progress
76
+ # Get all suites in the project
77
+ suites = get_all_suites (tr , project_id )
78
+ total_suites = len (suites )
79
+
80
+ # Process each suite
81
+ for index , suite in enumerate (suites , 1 ):
82
+ suite_id = suite ["id" ]
83
+ suite_name = suite ["name" ]
104
84
logging .info (f"Processing suite { index } /{ total_suites } : { suite_name } " )
105
85
106
86
try :
@@ -112,18 +92,16 @@ def set_untriaged_suitable_to_null_coverage(
112
92
status = case .get ("custom_automation_status" )
113
93
coverage = case .get ("custom_automation_coverage" )
114
94
115
- # Check if status is Untriaged or Suitable
95
+ # Check if status is Untriaged, Suitable, or Not Suitable
116
96
if status in [
117
97
AUTOMATION_STATUS ["UNTRIAGED" ],
118
98
AUTOMATION_STATUS ["SUITABLE" ],
99
+ AUTOMATION_STATUS ["NOT_SUITABLE" ],
119
100
]:
120
- # Check coverage value
121
- if coverage in [
122
- AUTOMATION_COVERAGE ["FULL" ],
123
- AUTOMATION_COVERAGE ["PARTIAL" ],
124
- ]:
101
+ # If coverage is not None, add to update targets
102
+ if coverage != AUTOMATION_COVERAGE ["NONE" ]:
125
103
update_targets .append (case )
126
- elif coverage == AUTOMATION_COVERAGE [ "NONE" ] :
104
+ else :
127
105
skipped_cases += 1
128
106
129
107
suite_update_count = len (update_targets )
@@ -143,14 +121,12 @@ def set_untriaged_suitable_to_null_coverage(
143
121
batch_ids = []
144
122
for case in batch :
145
123
case_id = case ["id" ]
146
- coverage = case .get ("custom_automation_coverage" )
147
- coverage_name = COVERAGE_NAMES .get (coverage )
148
-
149
- if coverage_name is None :
150
- logging .warning (
151
- f"Case { case_id } has unexpected coverage value: { coverage } "
152
- )
153
- coverage_name = "Unknown"
124
+ current_coverage = case .get (
125
+ "custom_automation_coverage"
126
+ )
127
+ coverage_name = COVERAGE_NAMES .get (
128
+ current_coverage , "Empty"
129
+ )
154
130
155
131
try :
156
132
tr .update_case_field (
@@ -175,15 +151,12 @@ def set_untriaged_suitable_to_null_coverage(
175
151
)
176
152
for case in batch :
177
153
case_id = case ["id" ]
178
- coverage = case .get ("custom_automation_coverage" )
179
- coverage_name = COVERAGE_NAMES .get (coverage )
180
-
181
- if coverage_name is None :
182
- logging .warning (
183
- f"Case { case_id } has unexpected coverage value: { coverage } "
184
- )
185
- coverage_name = "Unknown"
186
-
154
+ current_coverage = case .get (
155
+ "custom_automation_coverage"
156
+ )
157
+ coverage_name = COVERAGE_NAMES .get (
158
+ current_coverage , "Empty"
159
+ )
187
160
logging .info (
188
161
f" Case { case_id } - { coverage_name } → None"
189
162
)
@@ -242,7 +215,7 @@ def main():
242
215
243
216
# Process all cases in the project
244
217
logging .info (f"Processing project ID: { PROJECT_ID } ..." )
245
- set_untriaged_suitable_to_null_coverage (tr , PROJECT_ID , dry_run )
218
+ update_coverage_to_none (tr , PROJECT_ID , dry_run )
246
219
247
220
248
221
if __name__ == "__main__" :
0 commit comments