-
Notifications
You must be signed in to change notification settings - Fork 10
Hani/ Testrail exercise #541
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
import logging | ||
from modules.testrail_integration import testrail_init | ||
|
||
# Configuration | ||
PROJECT_ID = 17 | ||
SUITE_NAMES = ["Bookmarks and History", "Drag and Drop", "Find Toolbar"] | ||
AUTOMATION_COVERAGE_VALUE = 3 | ||
COMPLETED_STATUS_ID = 4 | ||
|
||
# Set TestRail credentials | ||
os.environ["TESTRAIL_BASE_URL"] = "https://mozilla.testrail.io" | ||
os.environ["TESTRAIL_USERNAME"] = "" | ||
os.environ["TESTRAIL_API_KEY"] = "" | ||
|
||
|
||
def get_all_completed_cases(tr, project_id, suite_id): | ||
"""Fetch all completed automated test cases (custom_automation_status = 4)""" | ||
response = tr._get_test_cases(project_id, suite_id) | ||
cases = response.get("cases", []) | ||
|
||
# Filter cases that are automated & completed (custom_automation_status == 4) | ||
completed_cases = [case for case in cases if case.get("custom_automated_test_names") and case.get("custom_automation_status") == 4] | ||
logging.info(f"Total cases fetched from suite {suite_id}: {len(completed_cases)}") | ||
return completed_cases | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
tr = testrail_init() | ||
|
||
# Get suite IDs for the selected suite names | ||
suites = tr.get_suites(PROJECT_ID) | ||
suite_ids = [suite["id"] for suite in suites if suite["name"] in SUITE_NAMES] | ||
logging.info(f"Found suites: {suite_ids}") | ||
|
||
all_completed_cases = [] | ||
for suite_id in suite_ids: | ||
completed_cases = get_all_completed_cases(tr, PROJECT_ID, suite_id) | ||
all_completed_cases.extend(completed_cases) | ||
|
||
logging.info(f"Total completed automated cases found for selected suites: {len(all_completed_cases)}") | ||
|
||
for case in all_completed_cases: | ||
tr.update_case_field(case["id"], "custom_automation_coverage", AUTOMATION_COVERAGE_VALUE) | ||
|
||
logging.info("All applicable test cases updated successfully!") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment this out, and insert a line that prints the case ids you would change if it ran live. Post that result here, and if it looks good, I'll give the go-ahead to run the script live. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Case IDs to be updated: [127239, 127249, 127271, 2084637, 2084639, 2084641, 2084539, 2084549, 2084489, 2084490, 2084518, 2084524, 2084550, 2084552, 2084553, 2084559, 2084564, 118799, 118800, 118802, 118805, 118806, 118807, 172043, 172045, 216273, 174072, 464474, 936860, 936861, 936864, 937418]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Total cases fetched from suite 2085: 3
Total cases fetched from suite 2525: 24
Total cases fetched from suite 5259: 5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks right, run the script!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the script successfully. Thanks.