本文整理汇总了Python中pyral.Rally类的典型用法代码示例。如果您正苦于以下问题:Python Rally类的具体用法?Python Rally怎么用?Python Rally使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Rally类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main(args):
options = [opt for opt in args if opt.startswith('--')]
args = [arg for arg in args if arg not in options]
server, user, password, workspace, project = rallySettings(options)
#print " ".join(["|%s|" % item for item in [server, user, '********', workspace, project]])
if not args:
errout("ERROR: You must supply an entity name!\n")
sys.exit(1)
entity = args[0]
if entity in ['UserStory', 'User Story', 'Story']:
entity = "HierarchicalRequirement"
#if '/' in entity:
# parent, entity = entity.split('/', 1)
try:
rally = Rally(server, user=user, password=password)
except Exception as ex:
errout(str(ex.args[0]))
sys.exit(1)
schema_item = rally.typedef(entity)
print schema_item
示例2: main
def main(args):
options = [opt for opt in args if opt.startswith('--')]
args = [arg for arg in args if arg not in options]
if not args:
print USAGE
sys.exit(9)
server, username, password, apikey, workspace, project = rallyWorkset(options)
if apikey:
rally = Rally(server, apikey=apikey, workspace=workspace, project=project)
else:
rally = Rally(server, user=username, password=password, workspace=workspace, project=project)
rally.enableLogging('rally.hist.chgsets') # name of file you want the logging to go to
repo_name = args.pop(0)
since = None
if args:
since = args.pop(0)
try:
days = int(since)
now = time.time()
since_ts = now - (days * 86400)
since = time.strftime("%Y-%m-%dT%H:%M:%S.000Z", time.gmtime(since_ts))
except:
since = None
showRepoItems(rally, repo_name, workspace=workspace, limit=ITEM_LIMIT, since_date=since)
示例3: Avant_Rally
class Avant_Rally(object):
iterations = []
rally = None
def __init__(self, project):
self.project = project
def connect(self, username, password):
self.rally = Rally(server, user, password, project=self.project)
self.rally.enableLogging('rally.simple-use.log')
def fetch_Iterations(self):
self.iterations = []
response = self.rally.get('Iteration', fetch=True)
for rls in response:
iter = Iteration()
rlsStart = rls.StartDate.split('T')[0] # just need the date part
rlsDate = rls.EndDate.split('T')[0] # ditto
self.iterations.append(iter.set_Iteration(rlsStart, rlsDate, rls.Name, rls.PlannedVelocity, self.rally))
def display_Iterations(self):
for i in self.iterations:
print "\n\n%s %s --> %s\t" % \
(i.name, i.start_date, i.end_date)
i.display_User_Stories(i.name)
示例4: test_get_distant_duplicated_project
def test_get_distant_duplicated_project():
"""
Using a known valid Rally server and known valid access credentials,
obtain a Rally instance and use it to obtain a Project instance for
a Project whose name contains multiple path elements with the elements
separated by the ' // ' token string.
Expect the result to return one and only one Project that is the correct Project.
The result should have the correct Parent Project.
When the Rally instance is called to setProject with the value of that
multi element path for the Project it should do so and should return the
correct value when asked for the current Project.
"""
rally = Rally(server=TRIAL, user=YETI_USER, password=YETI_PSWD,
workspace=BOONDOCKS_WORKSPACE, project=BOONDOCKS_PROJECT)
dupey_project = rally.getProject(DEEP_DUPE)
assert dupey_project is not None
assert dupey_project.__class__.__name__ == 'Project'
assert dupey_project.Name == DEEP_DUPE
criteria = 'Name = "%s"' % 'Corral'
expected_parent = rally.get('Project', fetch="Name,ObjectID,Parent,Children",
query=criteria, projectScopeDown=False, instance=True)
assert expected_parent is not None
assert expected_parent.__class__.__name__ == 'Project'
assert expected_parent.Name == 'Corral'
assert dupey_project.Parent.ref == expected_parent.ref
result = rally.setProject(DEEP_DUPE)
assert result is None
cur_project = rally.getProject()
assert cur_project.Name == DEEP_DUPE
示例5: test_two_conditions_query_as_dict
def test_two_conditions_query_as_dict():
rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD)
qualifiers = {'State' : 'Submitted',
'Ready' : 'False'
}
response = rally.get('Defect', fetch=True, query=qualifiers, limit=10)
assert response.resultCount > 0
示例6: test_set_mep_project_used_as_default_in_request_operation
def test_set_mep_project_used_as_default_in_request_operation():
"""
Using a known valid Rally server and known valid access credentials,
obtain a Rally instance associated with a unique Project name within a
valid Workspace.
Subsequently, set the instance's Project to a Project whose name is a duplicate.
The duplicate Project is specified as a path chain of:
baseProject // nextLevelProject // leafProject
At least one of the other non-target duplicates should exist in a shorter path.
Issue a request using the target duplicate Project m-e-p.
The result should be an Artifact whose projet matches the target duplicate Project
leaf name and ref exactly.
"""
rally = Rally(server=TRIAL, user=YETI_USER, password=YETI_PSWD,
workspace=BOONDOCKS_WORKSPACE, project=BOONDOCKS_PROJECT)
rally.setProject(DEEP_DUPE)
target_story = 'US3'
result = rally.get('Story', fetch="FormattedID,Name,Description,State,Project",
query='FormattedID = %s' % target_story,
projectScopeUp=False)
assert result is not None
assert result.resultCount > 0
stories = [story for story in result]
assert len(stories) > 0
hits = [story for story in stories if story.FormattedID == target_story]
assert len(hits) == 1
hit = hits[0]
assert hit.FormattedID == target_story
示例7: main
def main(args):
options = [opt for opt in args if opt.startswith('--')]
args = [arg for arg in args if arg not in options]
server, user, password, workspace, project = rallySettings(options)
#print " ".join(["|%s|" % item for item in [server, user, password, workspace, project]])
if not args:
print "You must supply an entity name!"
sys.exit(1)
query = ""
target = args[0]
if target in ['UserStory', 'User Story', 'Story']:
target = "HierarchicalRequirement"
if '/' in target:
parent, entity = target.split('/', 1)
target = entity
query = 'ElementName = "%s"' % target
try:
rally = Rally(server, user=user, password=password)
except Exception as ex:
errout(str(ex.args[0]))
sys.exit(1)
typedef = rally.typedef(target)
showAttributes(typedef.Attributes)
print ""
print "-" * 64
print ""
for ix, ancestor in enumerate(typedef.inheritanceChain()):
print "%s %s" % (" " * (ix*4), ancestor)
示例8: test_default_isolated_workspace
def test_default_isolated_workspace():
"""
Using a known valid Rally server and known valid access credentials,
obtain a Rally instance and confirm that the default workspace
and project are set to DEFAULT_WORKSPACE and DEFAULT_PROJECT and
that the current workspace and project are indeed the DEFAULT_WORKSPACE
and DEFAULT_PROJECT values.
Furthermore the construction of a GET related URL will contain
the correct workspace and project specifications in the QUERY_STRING.
And any attempt to change the workspace via rally.setWorkspace(some_name)
will result in a Exception being raised
"""
rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD, server_ping=False, isolated_workspace=True)
context1 = rally.contextHelper.currentContext()
workspace = rally.getWorkspace()
project = rally.getProject()
context2 = rally.contextHelper.currentContext()
assert context1 == context2
assert context1.workspace == DEFAULT_WORKSPACE
assert workspace.Name == DEFAULT_WORKSPACE
assert context1.project == DEFAULT_PROJECT
assert project.Name == DEFAULT_PROJECT
url = makeResourceUrl(rally, 'Defect')
#print(url)
expected_workspace_clause = 'workspace=workspace/%s' % str(workspace.oid)
assert expected_workspace_clause in url
problem_text = 'No reset of of the Workspace is permitted when the isolated_workspace option is specified'
with py.test.raises(Exception) as excinfo:
rally.setWorkspace(ALTERNATE_WORKSPACE)
actualErrVerbiage = excinfo.value.args[0]
assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
assert actualErrVerbiage == problem_text
示例9: main
def main(args):
options = [opt for opt in args if opt.startswith('--')]
args = [arg for arg in args if arg not in options]
if not args:
print USAGE
sys.exit(9)
# specify the Rally server and credentials
server, username, password, workspace, project = rallySettings(options)
#print " ".join(["|%s|" % opt for opt in [server, username, '********', workspace]])
rally = Rally(server, user=username, password=password, workspace=workspace, warn=False)
rally.enableLogging('rally.hist.chgsets') # name of file you want the logging to go to
repo_name = args.pop(0)
since = None
if args:
since = args.pop(0)
try:
days = int(since)
now = time.time()
since_ts = now - (days * 86400)
since = time.strftime("%Y-%m-%dT%H:%M:%S.000Z", time.gmtime(since_ts))
except:
since = None
showRepoItems(rally, repo_name, workspace=workspace, limit=ITEM_LIMIT, since_date=since)
示例10: test_bad_server_spec
def test_bad_server_spec():
"""
Use a known to be invalid server name using prohibited characters in the
server name.
Do the same test using default access credentials and known correct
valid credentials to an existing Rally server.
The status_code in the response must indicate a non-success condition.
"""
bad_server = "ww!w.\fo,o\r\n.c%om"
expectedErrMsg = "404 Target host: '%s' doesn't support the Rally WSAPI" % bad_server
altErrText = "non-existent or unreachable"
with py.test.raises(RallyRESTAPIError) as excinfo:
rally = Rally(server=bad_server, timeout=3)
response = rally.get('Project', fetch=False, limit=10)
actualErrVerbiage = excinfo.value.args[0] # becuz Python2.6 deprecates message :-(
assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
assert actualErrVerbiage == expectedErrMsg or altErrText in actualErrVerbiage
with py.test.raises(RallyRESTAPIError) as excinfo:
rally = Rally(server=bad_server,
user=TRIAL_USER,
password=TRIAL_PSWD, timeout=3)
response = rally.get('Project', fetch=False, limit=5)
actualErrVerbiage = excinfo.value.args[0] # becuz Python2.6 deprecates message :-(
assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
assert actualErrVerbiage == expectedErrMsg or altErrText in actualErrVerbiage
示例11: test_default_context
def test_default_context():
"""
Using a known valid Rally server and known valid access credentials,
obtain a Rally instance and confirm that the default workspace
and project are set to DEFAULT_WORKSPACE and DEFAULT_PROJECT and
that the current workspace and project are indeed the DEFAULT_WORKSPACE
and DEFAULT_PROJECT values.
Furthermore the construction of a GET related URL will contain
the correct workspace and project specifications in the QUERY_STRING.
"""
rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD, server_ping=False)
context1 = rally.contextHelper.currentContext()
workspace = rally.getWorkspace()
project = rally.getProject()
context2 = rally.contextHelper.currentContext()
assert context1 == context2
assert context1.workspace == DEFAULT_WORKSPACE
assert workspace.Name == DEFAULT_WORKSPACE
assert context1.project == DEFAULT_PROJECT
assert project.Name == DEFAULT_PROJECT
url = makeResourceUrl(rally, 'Defect')
#print(url)
expected_workspace_clause = 'workspace=workspace/%s' % str(workspace.oid)
assert expected_workspace_clause in url
expected_project_clause = 'project=project/%s' % str(project.oid)
assert expected_project_clause in url
示例12: test_bad_server_spec
def test_bad_server_spec():
"""
Use a known to be invalid server name using prohibited characters in the
server name.
Do the same test using default access credentials and known correct
valid credentials to an existing Rally server.
The status_code in the response must indicate a non-success condition.
"""
bad_server = "ww!w.\fo,o\r\n.c%om"
expectedErrMsg = "Unknown host"
with py.test.raises(RallyRESTAPIError) as excinfo:
rally = Rally(server=bad_server, timeout=3)
response = rally.get('Project', fetch=False, limit=10)
actualErrVerbiage = excinfo.value.args[0] # becuz Python2.6 deprecates message :-(
assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
assert 'cannot resolve' in actualErrVerbiage and 'Unknown host' in actualErrVerbiage
time.sleep(1)
with py.test.raises(RallyRESTAPIError) as excinfo:
rally = Rally(server=bad_server,
user=TRIAL_USER,
password=TRIAL_PSWD, timeout=3)
response = rally.get('Project', fetch=False, limit=5)
actualErrVerbiage = excinfo.value.args[0] # becuz Python2.6 deprecates message :-(
assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
assert 'cannot resolve' in actualErrVerbiage and 'Unknown host' in actualErrVerbiage
time.sleep(1)
示例13: test_getAllowedValues_for_UserStory_Milestone
def test_getAllowedValues_for_UserStory_Milestone():
"""
Using a known valid Rally server and known valid access credentials,
request allowed value information for the Milestones field of the UserStory entity.
The Milestones field is a standard field of schema type COLLECTION whose value
is entirely context dependent on the specific artifact so getting allowed values
doesn't really make sense in the same way as an attribute like State or Severity
that has a finite set of possible values that are the same for every Story or Defect
in the workspace. Because of that characteristic, we return a list with a single True
value ( [True] ) to designate that yes, technically the Milestones field has allowed
values but that asking for them on a specific AC artifact short-circuits. The proper
way to get all of the AllowedValues for Milestones is to query the Milestone entity
itself. There are numerous other standard attributes
with the same sort of semantic that are excluded from chasing the COLLECTION url and
returning some list of values. (like, Changesets, Discussions, Tags, etc.)
"""
rally = Rally(server=AGICEN, apikey=API_KEY)
avs = rally.getAllowedValues('Story', 'Milestones')
assert avs == [True]
response = rally.get('Milestone', fetch=True, workspace=LARGE_WORKSPACE,
project=LARGE_PROJECT_TREE_BASE, projectScopeDown=True)
milestones = [item for item in response]
assert len(milestones) > 150
# Given the singular name of the target field (which is invalid...) return a None value
avs = rally.getAllowedValues('Story', 'Milestone')
assert avs is None
示例14: main
def main(args):
options = [opt for opt in args if opt.startswith('--')]
args = [arg for arg in args if arg not in options]
server, user, password, workspace, project = rallySettings(options)
print " ".join(["|%s|" % item for item in [server, user, password, workspace, project]])
# add in the debug=True keyword arg if you want more verbiage ...
rally = Rally(server, user, password, workspace=workspace, project=project, debug=True)
workspace = rally.getWorkspace()
print "Workspace: %s " % workspace.Name
#print "Workspace: %12.12s %-18.18s (%s)" % (workspace.oid, workspace.Name, workspace.ref)
project = rally.getProject()
print "Project : %s " % project.Name
#print "Project : %12.12s %-18.18s (%s)" % (project.oid, project.Name, project.ref)
# uncomment this to see all of your accessible workspaces and projects
# workspaces = rally.getWorkspaces()
# for workspace in workspaces:
# print " ", workspace.Name
# projects = rally.getProjects(workspace=workspace.Name)
# if projects:
# print ""
# print " Projects:"
# for project in projects:
# print " ", project.Name
# else:
# print " No projects"
# print ""
sys.exit(0)
示例15: main
def main(args):
options = [opt for opt in args if opt.startswith('--')]
args = [arg for arg in args if arg not in options]
server, user, password, apikey, workspace, project = rallyWorkset(options)
rally = Rally(server, user, password, apikey=apikey, workspace=workspace, project=project)
entity_name = 'Milestone'
fields = 'FormattedID,Name,TargetProject,TargetDate,TotalArtifactCount'
response = rally.get(entity_name, fetch=fields, order="TargetDate,FormattedID",
project=project, projectScopeDown=True)
if response.errors:
errout("Request could not be successfully serviced, error code: %d\n" % response.status_code)
errout("\n".join(response.errors))
sys.exit(1)
if response.resultCount == 0:
errout('No items found for %s\n' % entity_name)
sys.exit(2)
milestones = [item for item in response]
sans_project = [mi for mi in milestones if not mi.TargetProject]
with_project = [mi for mi in milestones if mi.TargetProject]
with_project.sort(key=lambda mi: mi.TargetProject.Name)
for item in (with_project + sans_project):
proj_name = item.TargetProject.Name if item.TargetProject else ""
print(" %15.15s %-6.6s %-36.36s %3d %-10.10s %s " % \
(item.oid, item.FormattedID, item.Name,
item.TotalArtifactCount, item.TargetDate, proj_name))