Skip to content

Commit 456cad2

Browse files
committed
post review modifications dropping need for six in tests and restapi.py, minor cleanup in the context.py aisle
1 parent 0c54843 commit 456cad2

File tree

9 files changed

+17
-49
lines changed

9 files changed

+17
-49
lines changed

doc/source/interface.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Example use::
131131
print " ".join(['|%|' % opt for opt in [server, user, password, apikey, workspace, project]]
132132

133133

134-
% python basic.py --config=current --rallyProject="Livestock Mgmt" --no-ping
134+
% python basic.py --config=current --rallyProject="Livestock Mgmt" --ping=no
135135

136136
|rally1.rallydev.com| |[email protected]| |*****| |*****| |General Products Umbrella| |Livestock Mgmt|
137137

pyral/context.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
import re # we use compile, match
2020
from pprint import pprint
2121

22-
#import six
23-
2422
# intra-package imports
2523
from .rallyresp import RallyRESTResponse
2624
from .entity import processSchemaInfo, getSchemaItem
@@ -285,20 +283,18 @@ def _loadSubscription(self):
285283
self.context.subs_name = subscription.Name
286284
return subscription
287285

286+
288287
def _setOperatingContext(self, project_name):
289288
"""
290289
This is called after we've determined that there is access to what is now
291-
in self._defaultWorkspace. Query for projects in the self._defaultWorkspace.
290+
in self._currentWorkspace. Query for projects in the self._currentWorkspace.
292291
Set the self._defaultProject arbitrarily to the first Project.Name in the returned set,
293292
and then thereafter reset that to the project_name parameter value if a match for that
294293
exists in the returned set. If the project_name parameter is non-None and there is NOT
295294
a match in the returned set raise an Exception stating that fact.
296295
"""
297-
#result = self.agent.get('Project', fetch="Name", workspace=self._defaultWorkspace)
298296
result = self.agent.get('Project', fetch="Name", workspace=self._currentWorkspace)
299-
##
300-
## print(result.content)
301-
##
297+
302298
if not result or result.resultCount == 0:
303299
problem = "No Projects found in the Workspace '%s'" % self._defaultWorkspace
304300
raise RallyRESTAPIError(problem)
@@ -406,9 +402,6 @@ def _getDefaults(self, user_response):
406402
self._currentWorkspace = self._defaultWorkspace[:]
407403
wkspace_ref = up['DefaultWorkspace']['_ref']
408404
else:
409-
#self._currentWorkspace = self._defaultWorkspace.Name
410-
#wkspace_ref = self._defaultWorkspace._ref
411-
#self._defaultWorkspace = self._defaultWorkspace.Name
412405
self._defaultWorkspace = None
413406
self._currentWorkspace = None
414407
wkspace_ref = None
@@ -448,7 +441,6 @@ def _getSubscriptionWorkspaces(self, subscription, workspace=None, limit=0):
448441
## if not limit: print("Subscription %s has %d active Workspaces" % (subscription.Name, num_wksps))
449442
##
450443
self._subs_workspaces = subscription.Workspaces
451-
#self._defaultWorkspace = subscription.Workspaces[0]
452444
##
453445
## print("Subscription default Workspace: %s" % self._defaultWorkspace.Name)
454446
##
@@ -718,7 +710,6 @@ def identifyContext(self, **kwargs):
718710
augments.append("projectScopeDown=true")
719711

720712
if not workspace and project:
721-
#self.context = self.defaultContext
722713
self.context = self.operatingContext
723714

724715
# check to see if the _current_project is actually in the _current_workspace

pyral/restapi.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,6 @@ def getAllUsers(self, workspace=None):
573573
# and other UserProfile attributes
574574
]
575575

576-
#users_resource = 'users?fetch=true&query=&pagesize=%s&start=1&workspace=%s' % (MAX_PAGESIZE, workspace_ref)
577576
users_resource = 'users?fetch=%s&query=&pagesize=%s&start=1&workspace=%s' % (",".join(user_attrs), MAX_PAGESIZE, workspace_ref)
578577
full_resource_url = '%s/%s' % (self.service_url, users_resource)
579578
response = self.session.get(full_resource_url, timeout=SERVICE_REQUEST_TIMEOUT)
@@ -704,7 +703,6 @@ def _itemQuery(self, entityName, oid, workspace=None, project=None):
704703
raise RallyRESTAPIError('%s %s' % (response.status_code, problem))
705704

706705
response = RallyRESTResponse(self.session, context, '%s.x' % entityName, response, "full", 1)
707-
#item = six.next(response)
708706
item = response.next()
709707
return item # return back an instance representing the item
710708

@@ -911,7 +909,6 @@ def get(self, entity, fetch=False, query=None, order=None, **kwargs):
911909
response = self._getRequestResponse(context, full_resource_url, limit)
912910

913911
if kwargs and 'instance' in kwargs and kwargs['instance'] == True and response.resultCount == 1:
914-
#return six.next(response)
915912
return response.next()
916913
return response
917914

@@ -1032,7 +1029,6 @@ def post(self, entityName, itemData, workspace='current', project='current', **k
10321029
if response.status_code != HTTP_REQUEST_SUCCESS_CODE or response.resultCount == 0:
10331030
raise RallyRESTAPIError('Target %s %s could not be located' % (entityName, formattedID))
10341031

1035-
#target = six.next(response)
10361032
target = response.next()
10371033
oid = target.ObjectID
10381034
itemData['ObjectID'] = oid
@@ -1087,7 +1083,6 @@ def delete(self, entityName, itemIdent, workspace='current', project='current',
10871083
if response.status_code != HTTP_REQUEST_SUCCESS_CODE:
10881084
raise RallyRESTAPIError('Target %s %s could not be located' % (entityName, itemIdent))
10891085

1090-
#target = six.next(response)
10911086
target = response.next()
10921087
objectID = target.ObjectID
10931088
##
@@ -1458,7 +1453,6 @@ def addAttachment(self, artifact, filename, mime_type='text/plain'):
14581453

14591454
response = self.get('Attachment', fetch=True, query='Name = "%s"' % attachment_file_name)
14601455
if response.resultCount:
1461-
#attachment = six.next(response)
14621456
attachment = response.next()
14631457
already_attached = [att for att in current_attachments if att.oid == attachment.oid]
14641458
if already_attached:
@@ -1560,7 +1554,6 @@ def getAttachment(self, artifact, filename):
15601554
response = RallyRESTResponse(self.session, context, "AttachmentContent.x", resp, "full", 1)
15611555
if response.errors or response.resultCount != 1:
15621556
return None
1563-
#att_content = six.next(response)
15641557
att_content = response.next()
15651558
att.Content = base64.decodestring(att_content.Content) # maybe further txfm to Unicode ?
15661559
return att
@@ -1604,9 +1597,6 @@ def deleteAttachment(self, artifact, filename):
16041597

16051598
# get the target Attachment and the associated AttachmentContent item
16061599
attachment = hits.pop(0)
1607-
##
1608-
## print(attachment.details())
1609-
##
16101600
if attachment.Content and attachment.Content.oid:
16111601
success = self.delete('AttachmentContent', attachment.Content.oid, project=None)
16121602
if not success:
@@ -1651,7 +1641,6 @@ def _realizeArtifact(self, artifact):
16511641
art_type = self.ARTIFACT_TYPE[prefix]
16521642
response = self.get(art_type, fetch=True, query='FormattedID = %s' % artifact)
16531643
if response.resultCount == 1:
1654-
#artifact = six.next(response)
16551644
artifact = response.next()
16561645
else:
16571646
art_type = False
@@ -1730,7 +1719,6 @@ def _postRankRequest(self, target_artifact, resource, update_item):
17301719
workspace_ref = self.contextHelper.currentWorkspaceRef()
17311720
auth_token = self.obtainSecurityToken()
17321721
full_resource_url = "%s/%s&workspace=%s&key=%s" % (self.service_url, resource, workspace_ref, auth_token)
1733-
#print("rank%s full_resource_url: %s" % (direction, full_resource_url))
17341722
payload = json.dumps(update_item)
17351723
response = self.session.post(full_resource_url, data=payload, headers=RALLY_REST_HEADERS)
17361724
context = self.contextHelper.currentContext()

rallyfire.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import sys
1111

1212
from pyral import Rally, rallyWorkset
13-
from pyral import context
1413

1514
#################################################################################################
1615

test/test_attachments.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import types
55
import py
66

7-
import six
8-
97
import pyral
108
from pyral import Rally
119

@@ -62,7 +60,7 @@ def test_add_attachment():
6260
response = rally.get("UserStory", fetch="FormattedID,Name,Attachments",
6361
query='FormattedID = "%s"' % candidate_story)
6462
##print(response.resultCount)
65-
story = six.next(response)
63+
story = response.next()
6664
assert len(story.Attachments) == 0
6765

6866
attachment_name = "Addendum.txt"
@@ -74,7 +72,7 @@ def test_add_attachment():
7472

7573
response = rally.get("UserStory", fetch="FormattedID,Name,Attachments",
7674
query='FormattedID = "%s"' % candidate_story)
77-
story = six.next(response)
75+
story = response.next()
7876
assert len(story.Attachments) == 1
7977

8078

@@ -86,7 +84,7 @@ def test_get_attachment():
8684
target = 'FormattedID = "%s"' % candidate_story
8785
response = rally.get("UserStory", fetch=True, query=target, project=None)
8886
assert response.resultCount == 1
89-
story = six.next(response)
87+
story = response.next()
9088
##
9189
assert True == True
9290
return True
@@ -155,7 +153,7 @@ def test_detach_attachment():
155153

156154
response = rally.get("UserStory", fetch=True, query=target, project=None)
157155
assert response.resultCount == 1
158-
story = six.next(response)
156+
story = response.next()
159157
assert len(story.Attachments) == 1
160158
attachment = story.Attachments[0]
161159
expected_attachment_name = "Addendum.txt"

test/test_convenience.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import sys, os
44
import types
55
import pprint
6-
import six
76

87
from pyral import Rally
98

@@ -57,7 +56,6 @@ def test_getProject():
5756
assert response.warnings == []
5857

5958
assert response.resultCount > 0
60-
#proj_rec = six.next(response)
6159
proj_rec = response.next()
6260
#print proj_rec._ref
6361
#print proj_rec.ref

test/test_field_access.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import sys, os
44
import py
5-
import six
65

76
from pyral import Rally
87
import pyral
@@ -23,7 +22,7 @@ def test_story_fields():
2322
rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD)
2423
response = rally.get('Story', fetch=True, query=['NumberofCases = 9', 'AffectedCustomers = "abc, xyz"'])
2524
assert response.status_code == 200
26-
story = six.next(response)
25+
story = response.next()
2726

2827
assert story.NumberofCases == 9
2928
assert story.AffectedCustomers == 'abc, xyz'
@@ -40,7 +39,7 @@ def test_defect_fields():
4039
cust_field_criteria = {"BugzillaID" : 7224, "JiraKey" : "SLO-109", "QCDefectID" : 5724}
4140
response = rally.get('Defect', fetch=True, query=cust_field_criteria)
4241
assert response.status_code == 200
43-
defect = six.next(response)
42+
defect = response.next()
4443
assert defect.NumberofCases == 4
4544
assert 'def, jkl, qrs, uvw' in defect.AffectedCustomers
4645

test/test_inflation.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,9 @@ def test_named_non_default_workspace_named_valid_project():
171171
Return status should be OK, the Rally instance's RallyContextHelper
172172
_inflated value should be 'minimal'
173173
"""
174-
#workspace = 'JIRA Manual Testing'
175-
#project = 'Another Sample Project'
176-
workspace = "Kip's Playground"
177-
alt_project = 'Modus Operandi'
178-
rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD,
179-
workspace=workspace)
174+
workspace = "Kip's Playground"
175+
alt_project = 'Modus Operandi'
176+
rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD, workspace=workspace, warn=False)
180177
response = rally.get('Project')
181178
assert response != None
182179
assert response.status_code == 200

test/test_query.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import urllib
66
import py
77

8-
import six
9-
108
try:
119
from urllib import unquote
1210
except:
@@ -95,7 +93,7 @@ def test_good_and_bad_fields_query():
9593
"""
9694
rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD)
9795
response = rally.get('Project', fetch="Owner,State,Fabulote,GammaRays", limit=10)
98-
project = six.next(response)
96+
project = response.next()
9997
name = None
10098
state = None
10199
fabulote = None
@@ -168,8 +166,8 @@ def test_defects_revision_history():
168166
rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD)
169167
response = rally.get('Defect', fetch=True, limit=10)
170168

171-
defect1 = six.next(response)
172-
defect2 = six.next(response)
169+
defect1 = response.next()
170+
defect2 = response.next()
173171
assert defect1.oid != defect2.oid
174172

175173
d1_revs = defect1.RevisionHistory.Revisions
@@ -448,7 +446,7 @@ def test_query_with_matched_parens_in_condition_value():
448446
assert response.errors == []
449447
assert response.warnings == []
450448
assert response.resultCount >= 1
451-
release = six.next(response)
449+
release = response.next()
452450
assert release.Name == '8.5 (Blah and Stuff)'
453451

454452

0 commit comments

Comments
 (0)