Skip to content

Commit e4cbb9f

Browse files
committed
Set automation coverage to None for all the tests that have automation fields set to untriaged, suitable, not suitable
1 parent 6597f17 commit e4cbb9f

File tree

2 files changed

+38
-65
lines changed

2 files changed

+38
-65
lines changed

modules/testrail_scripts/testrail_script_set_untriaged_suitable_to_null_coverage.py renamed to modules/testrail_scripts/set_coverage_none_for_untriaged_suitable_notsuitable.py

Lines changed: 38 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,17 @@
77
from modules.testrail_integration import testrail_init
88

99
# 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")
1311

1412
# Load env file from project root
1513
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, "..", ".."))
1715
env_file_path = os.path.join(project_root, "testrail_credentials.env")
1816
load_dotenv(dotenv_path=env_file_path)
1917

2018
# TestRail project ID (Fx Desktop)
2119
PROJECT_ID = 17
2220

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-
5121
# Automation status values
5222
AUTOMATION_STATUS = {"UNTRIAGED": 1, "SUITABLE": 2, "NOT_SUITABLE": 3, "COMPLETED": 4}
5323

@@ -58,6 +28,13 @@
5828
COVERAGE_NAMES = {1: "None", 2: "Partial", 3: "Full"}
5929

6030

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+
6138
def get_all_test_cases(tr, project_id, suite_id):
6239
"""Fetch all test cases from a suite by handling pagination."""
6340
all_cases = []
@@ -83,11 +60,10 @@ def get_all_test_cases(tr, project_id, suite_id):
8360
return all_cases
8461

8562

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):
8964
"""
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
9167
"""
9268
start_time = time.time()
9369
try:
@@ -97,10 +73,14 @@ def set_untriaged_suitable_to_null_coverage(
9773
updated_count = 0
9874
changed_case_ids = [] # Track all case IDs that will be changed
9975

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"]
10484
logging.info(f"Processing suite {index}/{total_suites}: {suite_name}")
10585

10686
try:
@@ -112,18 +92,16 @@ def set_untriaged_suitable_to_null_coverage(
11292
status = case.get("custom_automation_status")
11393
coverage = case.get("custom_automation_coverage")
11494

115-
# Check if status is Untriaged or Suitable
95+
# Check if status is Untriaged, Suitable, or Not Suitable
11696
if status in [
11797
AUTOMATION_STATUS["UNTRIAGED"],
11898
AUTOMATION_STATUS["SUITABLE"],
99+
AUTOMATION_STATUS["NOT_SUITABLE"],
119100
]:
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"]:
125103
update_targets.append(case)
126-
elif coverage == AUTOMATION_COVERAGE["NONE"]:
104+
else:
127105
skipped_cases += 1
128106

129107
suite_update_count = len(update_targets)
@@ -143,14 +121,12 @@ def set_untriaged_suitable_to_null_coverage(
143121
batch_ids = []
144122
for case in batch:
145123
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+
)
154130

155131
try:
156132
tr.update_case_field(
@@ -175,15 +151,12 @@ def set_untriaged_suitable_to_null_coverage(
175151
)
176152
for case in batch:
177153
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+
)
187160
logging.info(
188161
f" Case {case_id} - {coverage_name} → None"
189162
)
@@ -242,7 +215,7 @@ def main():
242215

243216
# Process all cases in the project
244217
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)
246219

247220

248221
if __name__ == "__main__":

0 commit comments

Comments
 (0)