Skip to content

Commit 84c20e2

Browse files
committed
gross match to klehman-rally/pyral 1.6.0 master
1 parent b9ee9f9 commit 84c20e2

12 files changed

Lines changed: 848 additions & 77 deletions

.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
Addendum.txt
3+
4+
yeti*.cfg
5+
6+
.pypirc
7+
.*.swp
8+
9+
.DS_Store
10+
.idea/
11+
venv/
12+
pyral/__pycache__/
13+
14+
*.pyc
15+
test/rally_targets.py
16+
test/rally_targets-real.py
17+
test/rally_targets-safe.py
18+
test/raltargs.py
19+
test/.*.swp
20+
*.tar
21+
do_cover
22+
do_qt
23+
24+
collection-attrs
25+
dev-notes-for-1.2.0
26+
*1.2.*
27+
doc/build/html/pyral-docs.html.zip
28+
entity-new.py
29+
get*.py
30+
huuque.py
31+
examples/stryftr.py
32+
rally.cfg
33+
kip.cfg
34+
coll.cfg
35+
nick.cfg
36+
yodel.cfg
37+
examples/rally.cfg
38+
examples/yeti.cfg
39+
*.log
40+
holding-tank/
41+
temp/
42+
.cache
43+
rally-v2.0.cfg
44+
nmds.cfg
45+
notes-1.0.1
46+
notes-1.1.0
47+
notes-1.1.1
48+
query_condition_value_has_matched_internal_parens
49+
spec_char_query
50+
style.sins
51+
test/query_condition_value_has_matched_internal_parens
52+
test/wksp_proj_matrix.notes
53+
v2.notes*
54+
threading-performance.data
55+
codestyle.setup.cfg
56+
.coverage*
57+
cov_html/
58+
release-guide-*
59+
pyral-*.tar.gz
60+
pyral-*.zip
61+
dist/lab/
62+
dists/pyral-*.tgz
63+
dist/sdist-generated
64+
build/
65+
pkin.py

cr_milestone.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env python
2+
3+
#################################################################################################
4+
#
5+
# cr_milestone.py -- Create a Milestone instance with a Name and TargetDate
6+
#
7+
USAGE = """
8+
Usage: cr_milestone.py <name> <target_date>
9+
"""
10+
#################################################################################################
11+
12+
import sys, os
13+
from pyral import Rally, rallyWorkset
14+
15+
#################################################################################################
16+
17+
errout = sys.stderr.write
18+
19+
#################################################################################################
20+
21+
def main(args):
22+
options = [opt for opt in args if opt.startswith('--')]
23+
args = [arg for arg in args if arg not in options]
24+
25+
if len(args) != 2:
26+
print("No arguments for the Milestone Name or TargetDate were specified")
27+
sys.exit(1)
28+
29+
server, user, password, apikey, workspace, project = rallyWorkset(options)
30+
if apikey:
31+
rally = Rally(server, apikey=apikey, workspace=workspace, project=project)
32+
else:
33+
rally = Rally(server, user=user, password=password, workspace=workspace, project=project)
34+
35+
target_project = rally.getProject()
36+
target_entity_name = 'Milestone'
37+
milestone_name, milestone_target_date = args[:2]
38+
info = { 'Name' : milestone_name,
39+
'TargetDate' : milestone_target_date
40+
}
41+
42+
43+
print(f"Creating {target_entity_name} ...")
44+
milestone = rally.put(target_entity_name, info)
45+
print(f"Created Milestone: {milestone.FormattedID} OID: {milestone.oid} Name: {milestone.Name} TargetDate: {milestone.TargetDate}")
46+
47+
#################################################################################################
48+
#################################################################################################
49+
50+
if __name__ == '__main__':
51+
main(sys.argv[1:])

crbug.py

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/usr/bin/env python
2+
3+
#################################################################################################
4+
#
5+
# crbug.py -- Create a Bug, populate the Abundanza multi-select field in the 'Jira 7 Testing'
6+
# workspace
7+
#
8+
USAGE = """
9+
Usage: crbug.py
10+
"""
11+
#################################################################################################
12+
13+
import sys, os
14+
from pyral import Rally, rallyWorkset
15+
16+
#################################################################################################
17+
18+
errout = sys.stderr.write
19+
20+
#################################################################################################
21+
22+
def main(args):
23+
options = [opt for opt in args if opt.startswith('--')]
24+
args = [arg for arg in args if arg not in options]
25+
26+
server, user, password, apikey, workspace, project = rallyWorkset(options)
27+
if apikey:
28+
rally = Rally(server, apikey=apikey, workspace=workspace, project=project)
29+
else:
30+
rally = Rally(server, user=user, password=password, workspace=workspace, project=project)
31+
# rally.enableLogging("rally.history.crbug")
32+
33+
target_project = rally.getProject()
34+
target_entity_name = 'Defect'
35+
target_attribute_name = 'Abundanza'
36+
allowed_values = []
37+
candidate_values = ['bosch', 'rybosome', 'stihl', 'snap-on']
38+
value_refs = []
39+
40+
type_schema_attrs = rally.typedef(target_entity_name).Attributes
41+
ts_hits = [attr_schema for attr_schema in type_schema_attrs
42+
if attr_schema.ElementName == f'c_{target_attribute_name}']
43+
if ts_hits:
44+
tsa = ts_hits[0]
45+
allowed_values = tsa.AllowedValues
46+
47+
def notFound(target_value, allowed_values):
48+
hits = [aavs.value for aavs in allowed_values
49+
if aavs.value == target_value]
50+
return True if not hits else False
51+
52+
if allowed_values:
53+
disallowed_values = [cand_val for cand_val in candidate_values
54+
if notFound(cand_val, allowed_values)]
55+
if disallowed_values:
56+
for dav in disallowed_values:
57+
print(f'WARNING: {dav} is not an allowed value for the {target_entity_name}.{target_attribute_name} field')
58+
candidate_values = list(set(candidate_values) - set(disallowed_values))
59+
value_refs = getAllowedValueRefs(candidate_values, allowed_values)
60+
61+
info = {
62+
"Project" : target_project.ref,
63+
"Name" : "Mushy fries sicken our customers",
64+
"State" : "Submitted",
65+
"ScheduleState" : "Defined",
66+
"Description" : "revolt is soon to arrive at your franchise",
67+
"Notes" : "I have really only done some daydreaming wrt this defect",
68+
#"Abundanza" : "bosch,stihl,snap-on"
69+
"Abundanza" : value_refs
70+
}
71+
72+
print("Creating Defect ...")
73+
defect = rally.put('Defect', info)
74+
print("Created Defect: %s OID: %s" % (defect.FormattedID, defect.oid))
75+
#abund = defect.Abundanza
76+
abund = defect.c_Abundanza
77+
if abund:
78+
abund = ", ".join([aav.value for aav in abund])
79+
else:
80+
abund = ''
81+
82+
print(f' Abundanza: {abund}')
83+
#print(repr(defect.__dict__))
84+
#print(defect.details())
85+
86+
#################################################################################################
87+
88+
def getAllowedValueRefs(specified_values, allowed_values_schema):
89+
"""
90+
Turn the specified values into refs to the corresponding
91+
allowedattributevalue items.
92+
have to return a structure like:
93+
[
94+
{'_ref' : 'allowedattributevalue/875421254' },
95+
{'_ref' : 'allowedattributevalue/875432439' },
96+
...
97+
]
98+
"""
99+
ref_box = []
100+
for aav_text in specified_values:
101+
hits = [aavs.ref for aavs in allowed_values_schema
102+
if aavs.value == aav_text]
103+
if hits:
104+
ref = hits[0]
105+
ref_box.append({'_ref' : ref})
106+
return ref_box
107+
108+
#################################################################################################
109+
110+
111+
def emptyDefect():
112+
task = {'Workspace' : '',
113+
'Project' : '',
114+
'Name' : '',
115+
'State' : '',
116+
'ScheduleState' : '',
117+
}
118+
return task
119+
120+
#################################################################################################
121+
122+
def queryForDefects(rally):
123+
response = rally.get('Defect', fetch=True)
124+
# a response has status_code, content and data attributes
125+
126+
for defect in response:
127+
#print "%s %s %s %s" % (defect.__class__.__name__, defect.oid, defect.name, defect._ref)
128+
print("%s %s %s %s %s %s" % (defect.FormattedID, defect.Name,
129+
defect.Workspace.Name, defect.Project.Name,
130+
defect.Release.Name, defect.Iteration.Name))
131+
132+
#################################################################################################
133+
#################################################################################################
134+
135+
if __name__ == '__main__':
136+
main(sys.argv[1:])

examples/create_tcr.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/env python
2+
3+
#################################################################################################
4+
#
5+
# create_tcr.py -- Add TestCaseResult with relevant info AND links (refs) to a TestCase and TestSet
6+
#
7+
USAGE = """
8+
Usage: create_tcr.py <TestCase short_ref> <TestSet short_ref>
9+
"""
10+
#################################################################################################
11+
12+
import sys, os
13+
from pprint import pprint
14+
from pyral import Rally, rallyWorkset, restapi
15+
RallyRESTAPIError = restapi.RallyRESTAPIError
16+
17+
#################################################################################################
18+
19+
errout = sys.stderr.write
20+
21+
WORKSPACE = "/workspace/56371159504" # HPALM
22+
PROJECT = "/project/56371159588" # Test Project
23+
24+
TEST_CASE_REF = "/testcase/437141174052"
25+
TEST_SET_REF = "/testset/436906646904"
26+
27+
#TEST_CASE_REF = "/testcase/436896580816"
28+
#TEST_SET_REF = "/testset/436906646904"
29+
30+
build = "1847"
31+
run_date = "2020-09-22T16:23:20.000Z"
32+
verdict = "Pass"
33+
34+
zhpalm_run = {"Workspace" : "/workspace/56371159504", # HPALM
35+
"Project" : "/project/56371159588", # Test Project
36+
"TestCase" : "/testcase/436896580816", # lush green vistas
37+
"TestSet" : "/testset/436906646904", # HP12 complex test 3 rally test set HP release cycle
38+
"Build" : "3917",
39+
"Date" : "2020-09-21T23:03:20.000Z",
40+
"Verdict" : "Fail",
41+
}
42+
43+
44+
hpalm_run = {
45+
#"Workspace" : "/workspace/56371159504",
46+
"Workspace" : "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/56371159504",
47+
"Project" : "/project/56371159588",
48+
"TestCase" : "/testcase/61078205410",
49+
"TestSet" : "/testset/436906631556",
50+
"Build" : "load linked run #1",
51+
"Date" : "2020-09-03T21:50:48.000Z",
52+
"Verdict" : "Fail",
53+
"Duration" : "0",
54+
"Tester" : "https://rally1.rallydev.com/slm/webservice/v2.0/user/56374751020"
55+
}
56+
57+
#################################################################################################
58+
59+
def main(args):
60+
options = [opt for opt in args if opt.startswith('--')]
61+
args = [arg for arg in args if arg not in options]
62+
server, username, password, apikey, workspace, project = rallyWorkset(options)
63+
#if apikey:
64+
# rally = Rally(server, apikey=apikey, workspace=workspace, project=project)
65+
#else:
66+
# rally = Rally(server, user=username, password=password, workspace=workspace, project=project)
67+
rally = Rally(server, user=username, password=password, workspace=workspace, project=project)
68+
#rally.enableLogging("rally.hist.add_tcrs")
69+
70+
#if len(args) < 2:
71+
# errout(USAGE)
72+
# sys.exit(1)
73+
#test_case_ref, test_set_ref = args
74+
75+
tcr_data = { "Workspace" : WORKSPACE,
76+
"Project" : PROJECT,
77+
"TestCase" : TEST_CASE_REF,
78+
"TestSet" : TEST_SET_REF,
79+
"Build" : build,
80+
"Date" : run_date,
81+
"Verdict" : verdict
82+
}
83+
#pprint(tcr_data)
84+
#try:
85+
# tcr = rally.create('TestCaseResult', tcr_data)
86+
#except RallyRESTAPIError as details:
87+
# sys.stderr.write('ERROR: %s \n' % details)
88+
# sys.exit(4)
89+
90+
pprint(hpalm_run)
91+
try:
92+
tcr = rally.create('TestCaseResult', hpalm_run)
93+
except RallyRESTAPIError as details:
94+
sys.stderr.write('ERROR: %s \n' % details)
95+
sys.exit(4)
96+
97+
98+
#print(tcr.details())
99+
print("")
100+
print("Created TestCaseResult OID: %s TestCase: %s TestSet: %s" %
101+
(tcr.oid, tcr.TestCase.ref, tcr.TestSet.ref))
102+
print(" Build: %s Date: %s Verdict: %s" % (tcr.Build, tcr.Date, tcr.Verdict))
103+
104+
#################################################################################################
105+
#################################################################################################
106+
107+
if __name__ == '__main__':
108+
main(sys.argv[1:])
109+

0 commit comments

Comments
 (0)