Skip to content

Vs/refactoring2 #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
93d8297
vs/Part1-Refactoring
vsangereanMOZ Apr 8, 2025
4b1d2bd
vs/Refactoring 2
vsangereanMOZ Apr 30, 2025
1707ddd
Mark tests unstable
Tracy-Walker Apr 29, 2025
30cabe2
Fix Boookmarks tests
Tracy-Walker Apr 29, 2025
5aa69a9
Fix additional test
Tracy-Walker Apr 29, 2025
40a10a8
inital progress on poc
philimon-reset Apr 14, 2025
fcdd60f
continued efforts with live site POC
philimon-reset Apr 15, 2025
be7f2c8
broken change to ignore doorhanger
philimon-reset Apr 17, 2025
40cbb10
base structure for live testing set for walmart address page
philimon-reset Apr 17, 2025
70c03a4
amazon address field working
philimon-reset Apr 23, 2025
8c5cf0a
proof of concept complete
philimon-reset Apr 23, 2025
c7d461f
fix test create address profile
philimon-reset Apr 23, 2025
2bbd201
unfortunate mistake
philimon-reset Apr 23, 2025
ff0a4e5
live site access changed(only relevant for my local testing)
philimon-reset Apr 24, 2025
d13033a
further work to support DE and FR regions and clean up
philimon-reset Apr 24, 2025
1f5c922
webserver implemented
philimon-reset Apr 29, 2025
5be8bdd
amazon_ad minify
philimon-reset Apr 29, 2025
aa93def
region divide added
philimon-reset Apr 29, 2025
4b9c4be
canada address page for amazon added
philimon-reset Apr 29, 2025
b88e7e1
fix conftest
philimon-reset Apr 29, 2025
39e919d
remove loggin
philimon-reset Apr 29, 2025
fb7cd7b
l10n clean up
philimon-reset Apr 29, 2025
0437959
extra field for credit card base class.
philimon-reset Apr 29, 2025
96b6c45
revert change
philimon-reset Apr 29, 2025
4806fce
remove unnessary files
philimon-reset Apr 29, 2025
0a9d0c5
added amazon canada fix
philimon-reset Apr 30, 2025
cb5f594
Update null automation status to Untriaged
soncuteanca May 2, 2025
046a888
Merge branch 'main' into vs/Refactoring2
vsangereanMOZ May 5, 2025
60ba145
Merge branch 'main' into vs/Refactoring2
vsangereanMOZ May 5, 2025
1c40c43
Add files that were reverted.
vsangereanMOZ May 5, 2025
f04c64b
Merge remote-tracking branch 'origin/vs/Refactoring2' into vs/Refacto…
vsangereanMOZ May 5, 2025
3f62b33
Mark 2 tests as unstable.
vsangereanMOZ May 5, 2025
fbb6759
Merge remote-tracking branch 'origin/vs/Refactoring2' into vs/Refacto…
vsangereanMOZ May 5, 2025
139705b
Merge branch 'main' into vs/Refactoring2
vsangereanMOZ May 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update null automation status to Untriaged
  • Loading branch information
soncuteanca authored and vsangereanMOZ committed May 5, 2025
commit cb5f594f68e4d39b98ddb6676a9f40b0a47e3487
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ tests/test_scratch.py

# Credentials
credentials.json
testrail_credentials.env

# Do not ignore
!data/goomy.png
Expand Down
153 changes: 153 additions & 0 deletions modules/testrail_script_set_null_automation_status_to_untriaged.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import logging
import os

from dotenv import load_dotenv

from modules.testrail_integration import testrail_init

# Set up logging
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
)

# Load env file from project root
script_dir = os.path.dirname(__file__)
project_root = os.path.abspath(os.path.join(script_dir, ".."))
env_file_path = os.path.join(project_root, "testrail_credentials.env")
load_dotenv(dotenv_path=env_file_path)

# TestRail project ID (Fx Desktop)
PROJECT_ID = 17


def get_all_suites(tr, project_id):
"""Get all suites from the project"""
suites = tr.client.send_get(f"get_suites/{project_id}")
logging.info(f"Found {len(suites)} suites in project {project_id}")
return suites


# Set limit below maximum value as a precaution to avoid API errors
def get_all_test_cases(tr, project_id, suite_id):
"""Fetch all test cases from a suite by handling pagination."""
all_cases = []
offset = 0
limit = 240 # Default limit for TestRail API is 250

while True:
# Build endpoint with pagination parameters
endpoint = (
f"get_cases/{project_id}&suite_id={suite_id}&limit={limit}&offset={offset}"
)

response = tr.client.send_get(endpoint)
cases = response.get("cases", [])
if not cases:
break
all_cases.extend(cases)
# If the number of cases returned is less than the limit, we've reached the last page.
if len(cases) < limit:
break
offset += limit

logging.info(f"Total cases fetched from suite {suite_id}: {len(all_cases)}")
return all_cases


def update_null_automation_status(tr, project_id, dry_run=True):
"""Update test cases with None automation status to Untriaged"""
try:
# Get all suites in the project
suites = get_all_suites(tr, project_id)

# Track statistics
total_null_cases = 0
updated_count = 0

# Process each suite
for suite in suites:
suite_id = suite["id"]
suite_name = suite["name"]
logging.info(f"Processing suite {suite_name} (ID: {suite_id})...")

# Retrieve test cases for this suite
try:
cases = get_all_test_cases(tr, project_id, suite_id)

# Filter cases with null automation status
null_status_cases = [
case
for case in cases
if case.get("custom_automation_status") is None
]

suite_null_count = len(null_status_cases)
total_null_cases += suite_null_count

logging.info(
f"Found {suite_null_count} cases with null automation status in suite {suite_name}"
)

# Update each case that meets the criteria
for case in null_status_cases:
case_id = case["id"]
try:
if dry_run:
logging.info(
f"[DRY RUN] Would update case {case_id}: set automation status to Untriaged (1)"
)
else:
# Perform the update
tr.update_case_field(
case_id, "custom_automation_status", "1"
)
logging.info(
f"Updated case {case_id}: set automation status to Untriaged (1)"
)
updated_count += 1
except Exception as e:
logging.error(f"Error updating case {case_id}: {e}")
except Exception as e:
logging.error(f"Error processing suite {suite_id}: {e}")
continue

# Log summary
logging.info(
f"Summary: Found {total_null_cases} cases with null automation status across all suites"
)
if not dry_run:
logging.info(f"Updated {updated_count} cases to Untriaged")
else:
logging.info(
f"Would update {total_null_cases} cases to Untriaged (dry run)"
)

except Exception as e:
logging.error(f"Error processing cases: {e}")


def main():
# Read credentials from environment
base_url = os.environ.get("TESTRAIL_BASE_URL")
username = os.environ.get("TESTRAIL_USERNAME")
api_key = os.environ.get("TESTRAIL_API_KEY")

if not all([base_url, username, api_key]):
logging.error("Missing TestRail credentials. Check your .env file.")
return

logging.info(f"Loaded credentials for user: {username}")
logging.info(f"Base URL: {base_url}")

tr = testrail_init()

# Safe approach to not accidentally update cases
dry_run = True

# Process all cases in the project
logging.info(f"Processing project ID: {PROJECT_ID}...")
update_null_automation_status(tr, PROJECT_ID, dry_run)


if __name__ == "__main__":
main()
Loading