Skip to content

Pat/Finished TR exercise #537

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
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions modules/testrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ def __init__(self, host, username, password, local=False):
def get_test_case(self, case_id):
"""Get a given Test Case"""
return self.client.send_get(f"get_case/{case_id}")

def get_suites(self, project_id):
"""Get all suites for project"""
return self.client.send_get(f"get_suites/{project_id}")

def update_cases_in_suite(self, suite_id, case_ids, **kwargs):
"""Given a suite and a list of test cases, update all listed
Expand Down
28 changes: 28 additions & 0 deletions update_test_cases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os, logging
import modules.testrail_integration as tri

SUITES = ["Form Autofill", "Geolocation", "Language Packs"]
FULL_COVERAGE_VALUE = 3


def main():
# Set env variables for testrail_init function
os.environ["TESTRAIL_BASE_URL"] = "https://mozilla.testrail.io"
os.environ["TESTRAIL_USERNAME"] = "user"
os.environ["TESTRAIL_API_KEY"] = "api_key"
tr = tri.testrail_init()

# Get all suites from our project
for suite in tr.get_suites(17):
if suite["name"] not in SUITES:
continue
# Loop through all the test cases in the target suite
for case in tr._get_test_cases(17, suite["id"])["cases"]:
# Check if the custom automated field is set to see if we automated it
if case["custom_automated_test_names"]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this is exactly how we want to check whether a case has been automated, but it might work? If you comment out the updater line below and print which cases this would update, what do you get?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would get all the test cases, so a big big chunk of tests

logging.info(f"Updating test case {case['id']} coverage status for full")
tr.update_case_field(case['id'], "custom_automation_coverage", FULL_COVERAGE_VALUE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment this out and write a line that prints all the case numbers you would be updating, if it looks good I'll give the go-ahead

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a screenshot:
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, run the script!



if __name__ == "__main__":
main()