-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path__main__.py
121 lines (101 loc) · 3.87 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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, PROJECTS_DESKTOP, PLATFORMS, 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, Ecosystem or Desktop",
required=False,
choices=PLATFORMS,
)
parser.add_argument(
"--report-type",
help="Indicate report type",
required=False,
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 in ('test-case-coverage', 'testrail-milestones'):
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)
elif platform == 'desktop' and project not in PROJECTS_DESKTOP:
print(f"Error: Invalid project '{project}' for desktop. Valid options are {PROJECTS_DESKTOP}") # noqa
sys.exit(1)
def args_to_list(platform, projects):
projects_list = []
# we need to convert projects data, if str, to a list (if not already)
if isinstance(projects, str):
if projects == 'all':
if platform == 'desktop':
for project in PROJECTS_DESKTOP[:-1]:
projects_list.append(project)
if platform == 'mobile':
for project in PROJECTS_MOBILE[:-1]:
projects_list.append(project)
if platform == 'ecosystem':
for project in PROJECTS_ECOSYSTEM[:-1]:
projects_list.append(project)
else:
projects_list = [projects]
return projects_list
def main():
args = parse_args(sys.argv[1:])
validate_project(args.platform, args.project, args.report_type)
arg_list = args_to_list(args.platform.lower(), args.project.lower())
if args.report_type == 'test-case-coverage':
h = TestRailClient()
h.data_pump(arg_list)
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 == 'testrail-milestones':
h = TestRailClient()
h.testrail_milestones(arg_list)
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()