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
- AUTOMATION_STATUS = {"UNTRIAGED" : 1 , "SUITABLE" : 2 , "NOT_SUITABLE" : 3 , "COMPLETED" : 4 }
22
+ AUTOMATION_STATUS = {
23
+ "UNTRIAGED" : 1 ,
24
+ "SUITABLE" : 2 ,
25
+ "NOT_SUITABLE" : 3 ,
26
+ "COMPLETED" : 4 ,
27
+ "DISABLED" : 5 ,
28
+ }
53
29
54
30
# Automation coverage values
55
31
AUTOMATION_COVERAGE = {"NONE" : 1 , "PARTIAL" : 2 , "FULL" : 3 }
56
32
57
33
# Coverage value to name mapping for better logging
58
34
COVERAGE_NAMES = {1 : "None" , 2 : "Partial" , 3 : "Full" }
59
35
36
+ # Status value to name mapping for better logging
37
+ STATUS_NAMES = {
38
+ 1 : "Untriaged" ,
39
+ 2 : "Suitable" ,
40
+ 3 : "Unsuitable" ,
41
+ 4 : "Completed" ,
42
+ 5 : "Disabled" ,
43
+ }
44
+
45
+
46
+ def get_all_suites (tr , project_id ):
47
+ """Get all suites from the project"""
48
+ suites = tr .client .send_get (f"get_suites/{ project_id } " )
49
+ logging .info (f"Found { len (suites )} suites in project { project_id } " )
50
+ return suites
51
+
60
52
61
53
def get_all_test_cases (tr , project_id , suite_id ):
62
54
"""Fetch all test cases from a suite by handling pagination."""
@@ -83,11 +75,10 @@ def get_all_test_cases(tr, project_id, suite_id):
83
75
return all_cases
84
76
85
77
86
- def set_untriaged_suitable_to_null_coverage (
87
- tr , project_id , dry_run = True , batch_size = 25
88
- ):
78
+ def update_coverage_to_none (tr , project_id , dry_run = True , batch_size = 25 ):
89
79
"""
90
- Set automation coverage to None for test cases that have automation status of Untriaged or Suitable
80
+ Set automation coverage to None for all test cases that have automation status of
81
+ Untriaged, Suitable, or Not Suitable, regardless of their current coverage value
91
82
"""
92
83
start_time = time .time ()
93
84
try :
@@ -97,10 +88,14 @@ def set_untriaged_suitable_to_null_coverage(
97
88
updated_count = 0
98
89
changed_case_ids = [] # Track all case IDs that will be changed
99
90
100
- # Process each specified suite
101
- total_suites = len (SUITES )
102
- for index , (suite_id , suite_name ) in enumerate (SUITES , 1 ):
103
- # Show progress
91
+ # Get all suites in the project
92
+ suites = get_all_suites (tr , project_id )
93
+ total_suites = len (suites )
94
+
95
+ # Process each suite
96
+ for index , suite in enumerate (suites , 1 ):
97
+ suite_id = suite ["id" ]
98
+ suite_name = suite ["name" ]
104
99
logging .info (f"Processing suite { index } /{ total_suites } : { suite_name } " )
105
100
106
101
try :
@@ -112,18 +107,17 @@ def set_untriaged_suitable_to_null_coverage(
112
107
status = case .get ("custom_automation_status" )
113
108
coverage = case .get ("custom_automation_coverage" )
114
109
115
- # Check if status is Untriaged or Suitable
110
+ # Check if status is one that should have None coverage
116
111
if status in [
117
112
AUTOMATION_STATUS ["UNTRIAGED" ],
118
113
AUTOMATION_STATUS ["SUITABLE" ],
114
+ AUTOMATION_STATUS ["NOT_SUITABLE" ],
115
+ AUTOMATION_STATUS ["DISABLED" ],
119
116
]:
120
- # Check coverage value
121
- if coverage in [
122
- AUTOMATION_COVERAGE ["FULL" ],
123
- AUTOMATION_COVERAGE ["PARTIAL" ],
124
- ]:
117
+ # If coverage is not None, add to update targets
118
+ if coverage != AUTOMATION_COVERAGE ["NONE" ]:
125
119
update_targets .append (case )
126
- elif coverage == AUTOMATION_COVERAGE [ "NONE" ] :
120
+ else :
127
121
skipped_cases += 1
128
122
129
123
suite_update_count = len (update_targets )
@@ -143,14 +137,12 @@ def set_untriaged_suitable_to_null_coverage(
143
137
batch_ids = []
144
138
for case in batch :
145
139
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"
140
+ current_coverage = case .get (
141
+ "custom_automation_coverage"
142
+ )
143
+ coverage_name = COVERAGE_NAMES .get (
144
+ current_coverage , "Empty"
145
+ )
154
146
155
147
try :
156
148
tr .update_case_field (
@@ -175,17 +167,18 @@ def set_untriaged_suitable_to_null_coverage(
175
167
)
176
168
for case in batch :
177
169
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
-
170
+ current_status = case .get ("custom_automation_status" )
171
+ current_coverage = case .get (
172
+ "custom_automation_coverage"
173
+ )
174
+ status_name = STATUS_NAMES .get (
175
+ current_status , "Unknown"
176
+ )
177
+ coverage_name = COVERAGE_NAMES .get (
178
+ current_coverage , "Empty"
179
+ )
187
180
logging .info (
188
- f" Case { case_id } - { coverage_name } → None"
181
+ f" Case { case_id } - Status: { status_name } , Coverage: { coverage_name } → None"
189
182
)
190
183
changed_case_ids .append ((case_id , suite_name ))
191
184
@@ -242,7 +235,7 @@ def main():
242
235
243
236
# Process all cases in the project
244
237
logging .info (f"Processing project ID: { PROJECT_ID } ..." )
245
- set_untriaged_suitable_to_null_coverage (tr , PROJECT_ID , dry_run )
238
+ update_coverage_to_none (tr , PROJECT_ID , dry_run )
246
239
247
240
248
241
if __name__ == "__main__" :
0 commit comments