-
Notifications
You must be signed in to change notification settings - Fork 5
/
__main__.py
93 lines (77 loc) · 2.76 KB
/
__main__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import argparse
import sys
from bugz import BugzillaClient
from github import GithubClient
from jira import JiraClient
from testrail import TestRailClient
from utils.constants import PROJECTS_MOBILE, PROJECTS_ECOSYSTEM, PLATFORM, REPORT_TYPES # noqa
def parse_args(cmdln_args):
parser = argparse.ArgumentParser(
description="Retrieve and update mobile project test data"
)
parser.add_argument(
"--project",
help="Indicate project",
required=False,
)
parser.add_argument(
"--platform",
help="Select the platform Mobile or Ecosystem",
required=False,
choices=PLATFORM,
)
parser.add_argument(
"--report-type",
help="Indicate report type",
required=True,
choices=REPORT_TYPES
)
parser.add_argument(
"--num-days",
help="Indicate number of historic days of records to include",
required=False
)
return parser.parse_args(args=cmdln_args)
# Function to validate the project based on the platform
def validate_project(platform, project, report_type):
# Conditionally require --platform and --project
# if --report-type is 'test-case-coverage'
if report_type == 'test-case-coverage':
if not project:
print("--project is required for the report selected")
if not platform:
print("--platform is required for the report selected")
if platform == 'mobile' and project not in PROJECTS_MOBILE:
print(f"Error: Invalid project '{project}' for mobile. Valid options are {PROJECTS_MOBILE}") # noqa
sys.exit(1)
elif platform == 'ecosystem' and project not in PROJECTS_ECOSYSTEM:
print(f"Error: Invalid project '{project}' for ecosystem. Valid options are {PROJECTS_ECOSYSTEM}") # noqa
sys.exit(1)
def main():
args = parse_args(sys.argv[1:])
validate_project(args.platform, args.project, args.report_type)
if args.report_type == 'test-case-coverage':
h = TestRailClient()
h.data_pump(args.project.lower())
if args.report_type == 'test-run-counts':
h = TestRailClient()
if args.num_days:
num_days = args.num_days
else:
num_days = ''
h.testrail_run_counts_update(args.project, num_days)
if args.report_type == 'issue-regression':
h = GithubClient()
h.github_issue_regression(args.project)
h = GithubClient()
if args.report_type == 'jira-qa-requests':
h = JiraClient()
h.jira_qa_requests()
if args.report_type == 'jira-qa-needed':
h = JiraClient()
h.jira_qa_needed()
if args.report_type == 'bugzilla-qe-verify':
h = BugzillaClient()
h.bugzilla_qe_verify()
if __name__ == '__main__':
main()