本文整理汇总了Python中pyral.Rally.setProject方法的典型用法代码示例。如果您正苦于以下问题:Python Rally.setProject方法的具体用法?Python Rally.setProject怎么用?Python Rally.setProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyral.Rally
的用法示例。
在下文中一共展示了Rally.setProject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_mep_project_used_as_default_in_request_operation
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
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
示例2: test_initial_non_default_workspace_as_isolated
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
def test_initial_non_default_workspace_as_isolated():
rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD,
workspace=ALTERNATE_WORKSPACE,
warn=False, isolated_workspace=True)
# Because no project=name arg was supplied, the project will be the User's default project
# which will not necessarily be valid for the workspace argument that was supplied
workspace = rally.getWorkspace()
assert workspace.Name == ALTERNATE_WORKSPACE
project = rally.getProject()
assert project.Name == DEFAULT_PROJECT
rally.setProject(ALTERNATE_PROJECT)
project = rally.getProject()
assert project.Name == ALTERNATE_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
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(DEFAULT_WORKSPACE)
actualErrVerbiage = excinfo.value.args[0]
assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
assert actualErrVerbiage == problem_text
示例3: main
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
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]])
rally = Rally(server, user, password, workspace=workspace, project=project)
rally.enableLogging('rally.hist.statecount') # name of file you want logging to go to
if not args:
errout(USAGE)
sys.exit(1)
rally.setWorkspace(workspace)
rally.setProject(project)
artifact_type = args[0]
if artifact_type not in VALID_ARTIFACT_TYPES:
errout(USAGE)
errout('The artifact_type argument must be one of: %s\n' % ", ".join(VALID_ARTIFACT_TYPES))
sys.exit(1)
art_type = artifact_type[:]
state = 'State' # default to this and change below if necessary
if artifact_type in ['Story', 'UserStory', 'HierarchicalRequirement']:
artifact_type = 'HierarchicalRequirement'
state = 'ScheduleState'
t_zero = time.time()
state_values = rally.getAllowedValues(artifact_type, state)
t_one = time.time()
av_time = t_one - t_zero
show_counts(rally, artifact_type, state, state_values, av_time)
示例4: test_default_wksprj_set_non_default_wksprj_specify_workspace_and_project_equal_None_context
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
def test_default_wksprj_set_non_default_wksprj_specify_workspace_and_project_equal_None_context():
rally = Rally(server=AGICEN, user=AGICEN_USER, password=AGICEN_PSWD)
workspace = rally.getWorkspace()
assert workspace.Name == DEFAULT_WORKSPACE
project = rally.getProject()
assert project.Name == DEFAULT_PROJECT
rally.setWorkspace(ALTERNATE_WORKSPACE)
workspace = rally.getWorkspace()
assert workspace.Name == ALTERNATE_WORKSPACE
#problem_text = 'Specified project not valid for your current workspace or credentials'
#with py.test.raises(Exception) as excinfo:
# rally.setProject(ALTERNATE_PROJECT)
#actualErrVerbiage = excinfo.value.args[0] # becuz Python2.6 deprecates message :-(
#assert excinfo.value.__class__.__name__ == 'Exception'
#assert actualErrVerbiage == problem_text
rally.setProject(ALTERNATE_PROJECT)
project = rally.getProject()
assert project.Name == ALTERNATE_PROJECT
url = makeResourceUrl(rally, 'Defect', workspace=None, project=None)
#print(url)
assert '&workspace=' not in url
assert '&project=' not in url
示例5: test_default_wksprj_with_set_non_default_workspace_context
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
def test_default_wksprj_with_set_non_default_workspace_context():
rally = Rally(server=AGICEN, user=AGICEN_USER, password=AGICEN_PSWD)
workspace = rally.getWorkspace()
assert workspace.Name == DEFAULT_WORKSPACE
project = rally.getProject()
assert project.Name == DEFAULT_PROJECT
url = makeResourceUrl(rally, 'Defect')
expected_workspace_clause = 'workspace=workspace/%s' % str(workspace.oid)
expected_project_clause = 'project=project/%s' % str(project.oid)
assert expected_workspace_clause in url
assert expected_project_clause in url
rally.setWorkspace(ALTERNATE_WORKSPACE)
workspace = rally.getWorkspace()
assert workspace.Name == ALTERNATE_WORKSPACE
rally.setProject(ALTERNATE_PROJECT)
project = rally.getProject()
assert project.Name == ALTERNATE_PROJECT
url = makeResourceUrl(rally, 'Defect')
expected_workspace_clause = 'workspace=workspace/%s' % str(workspace.oid)
expected_project_clause = 'project=project/%s' % str(project.oid)
assert expected_workspace_clause in url
assert expected_project_clause in url
示例6: test_get_distant_duplicated_project
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
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
示例7: test_named_non_default_workspace_named_valid_project
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
def test_named_non_default_workspace_named_valid_project():
"""
Using valid Rally access credentials, connect specifying
a valid non-default workspace and a valid project.
Return status should be OK, the Rally instance's RallyContextHelper
_inflated value should be 'minimal'
"""
workspace = "Kip's Playground"
alt_project = 'Modus Operandi'
rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD, workspace=workspace, warn=False)
response = rally.get('Project')
assert response != None
assert response.status_code == 200
assert rally._wpCacheStatus() == 'narrow'
rally.setProject(alt_project)
proj = rally.getProject()
assert proj.Name == alt_project
示例8: test_default_wksprj_with_set_non_default_workspace_and_project_specify_project_equal_None_context
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
def test_default_wksprj_with_set_non_default_workspace_and_project_specify_project_equal_None_context():
rally = Rally(server=AGICEN, user=AGICEN_USER, password=AGICEN_PSWD)
workspace = rally.getWorkspace()
assert workspace.Name == DEFAULT_WORKSPACE
project = rally.getProject()
rally.setWorkspace(ALTERNATE_WORKSPACE)
workspace = rally.getWorkspace()
assert workspace.Name == ALTERNATE_WORKSPACE
rally.setProject(ALTERNATE_PROJECT)
project = rally.getProject()
assert project.Name == ALTERNATE_PROJECT
url = makeResourceUrl(rally, 'Defect', project=None)
#print(url)
expected_workspace_clause = 'workspace=workspace/%s' % str(workspace.oid)
assert expected_workspace_clause in url
assert '&project=' not in url
示例9: test_default_wksprj_set_non_default_wksprj_specify_workspace_and_project_equal_None_context
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
def test_default_wksprj_set_non_default_wksprj_specify_workspace_and_project_equal_None_context():
rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD)
workspace = rally.getWorkspace()
assert workspace.Name == DEFAULT_WORKSPACE
project = rally.getProject()
assert project.Name == DEFAULT_PROJECT
rally.setWorkspace(ALTERNATE_WORKSPACE)
workspace = rally.getWorkspace()
assert workspace.Name == ALTERNATE_WORKSPACE
rally.setProject(ALTERNATE_PROJECT)
project = rally.getProject()
assert project.Name == ALTERNATE_PROJECT
url = makeResourceUrl(rally, 'Defect', workspace=None, project=None)
#print url
assert '&workspace=' not in url
assert '&project=' not in url
示例10: test_query_with_special_chars_in_criteria
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
def test_query_with_special_chars_in_criteria():
"""
DE3228 in DEFAULT_WORKSPACE / NON_DEFAULT_PROJECT has Name = Special chars:/[email protected]#$%^&*()-=+[]{};:./<>?/
query for it by looking for it by the name value
"""
rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD)
rally.setWorkspace(DEFAULT_WORKSPACE)
rally.setProject(NON_DEFAULT_PROJECT)
rally.enableLogging('spec_char_query')
criteria = 'Name = "distinctive criteria of -32% degradation in rust protection"'
response = rally.get('Defect', fetch=True, query=criteria, limit=10)
assert response.__class__.__name__ == 'RallyRESTResponse'
assert response.status_code == 200
assert response.errors == []
assert response.warnings == []
assert response.resultCount == 1
criteria = 'Name = "Looking for the #blowback hashtag"'
response = rally.get('Defect', fetch=True, query=criteria, limit=10)
assert response.status_code == 200
assert response.errors == []
assert response.warnings == []
assert response.resultCount == 1
special_chars = "/[email protected]#$%^*_-+=?{}[]:;,<>"
# characters that break the RallyQueryFormatter and/or WSAPI: ( ) ~ & | backslash
for character in special_chars:
criteria = 'Name contains "%s"' % character
response = rally.get('Defect', fetch=True, query=criteria, limit=10)
assert response.__class__.__name__ == 'RallyRESTResponse'
assert response.status_code == 200
assert response.errors == []
assert response.warnings == []
assert response.resultCount >= 1
criteria = 'Name = "Special chars:/[email protected]#$%^*-=+[]{};:.<>? in the name field"'
response = rally.get('Defect', fetch=True, query=criteria, limit=10)
assert response.__class__.__name__ == 'RallyRESTResponse'
assert response.status_code == 200
assert response.errors == []
assert response.warnings == []
assert response.resultCount >= 1
示例11: test_initial_workspace_not_default
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
def test_initial_workspace_not_default():
rally = Rally(server=AGICEN, user=AGICEN_USER, password=AGICEN_PSWD,
workspace=ALTERNATE_WORKSPACE,
warn=False)
# Because no project=name arg was supplied, the project will be the User's default project
# which will not necessarily be valid for the workspace argument that was supplied
workspace = rally.getWorkspace()
assert workspace.Name == ALTERNATE_WORKSPACE
project = rally.getProject()
assert project.Name == DEFAULT_PROJECT
rally.setProject(ALTERNATE_PROJECT)
project = rally.getProject()
assert project.Name == ALTERNATE_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: main
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
def main(args):
options = [opt for opt in args if opt.startswith('--')]
args = [arg for arg in args if arg not in options]
server, username, password, apikey, workspace, project = rallyWorkset(options)
rally = Rally(server, username, password, apikey=apikey, workspace=workspace)
wksp = rally.getWorkspace()
print("Workspace: %s" % wksp.Name)
print("=" * (len(wksp.Name) + 12))
print("")
for project in PROJECTS:
rally.setProject(project)
print(" %s" % project)
print(" %s" % ('-' * len(project)))
print("")
response = getSchedulableArtifacts(rally)
showSchedulableArtifacts(response)
print("")
print("-" * 80)
print("")
print("%d items" % response.resultCount)
print("")
示例13: range
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
if args.tests_path.strip() != '':
from pyral import Rally
from time import sleep
#TODO Hipchat integration
from hypchat import HypChat
# Switch to know if the script got the connection to the Rally server
connected = False
# Try to reconnect to the server it the connection fails
for retry in range(0, 4):
try:
with open(args.config_file) as config_file:
config = json.load(config_file)
rally = Rally(config['RALLY_SERVER'], config['RALLY_USER'], config['RALLY_PASSWORD'], WORKSPACE=config['RALLY_WORKSPACE'])
rally.enableLogging(config['RALLY_LOGGER'])
rally.setProject(args.project)
connected = True
break
except Exception, details:
log.error('Cannot connect to the Rally Server.\n')
log.error('DETAILS: %s' % details)
log.info('Retrying (try #%d)...\n\n' % (retry+1))
sleep(5)
if not connected:
log.error('The connection to the Rally server has failed.')
exit(0)
tests_path = args.tests_path
teststorally = TestToRally(rally, config, args.regex_json)
task_name = args.task_name
if task_name in dir(teststorally):
示例14: test_query_using_project_scoping_options
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
def test_query_using_project_scoping_options():
"""
Target a Project that has subprojects with a population of Stories for a query,
using the projectScopeDown=False and then again with projectScopeDown=True.
The query specifying projectScopeDown=True should return more Stories than the initial query
"""
SCOPE_ROOT_PROJECT = 'Arctic Elevation'
rally = Rally(server=AGICEN, user=AGICEN_USER, password=AGICEN_PSWD)
projects = rally.getProjects(workspace=DEFAULT_WORKSPACE)
rally.setProject(SCOPE_ROOT_PROJECT)
response = rally.get('Story', fetch="FormattedID,Name,State,Project")
#assert response.resultCount == 11 # pre 1.2.4 behavior
assert response.resultCount == 4 # expected 1.2.4 behavior
response = rally.get('Story', fetch="FormattedID,Name,State", projectScopeDown=True)
assert response.resultCount == 11
response = rally.get('Story', fetch="FormattedID,Name,State", projectScopeDown=False)
assert response.resultCount == 4
ISOLATED_SUB_PROJECT = 'Aurora Borealis'
#print("\nISOLATED_SUB_PROJECT: %s" % ISOLATED_SUB_PROJECT)
response = rally.get('Story', fetch="FormattedID,Name,State,Project",
project=ISOLATED_SUB_PROJECT, projectScopeDown=False,
order="FormattedID,Project.Name")
assert response.resultCount == 2
response = rally.get('Story', fetch="FormattedID,Name,State",
project=ISOLATED_SUB_PROJECT, projectScopeDown=True)
assert response.resultCount == 2
response = rally.get('Story', fetch="FormattedID,Name,State",
project=ISOLATED_SUB_PROJECT, projectScopeUp=True)
assert response.resultCount == 6
BEEFIER_SUB_PROJECT = 'Sub Arctic Conditions'
#print("BEEFIER_SUB_PROJECT: %s" % BEEFIER_SUB_PROJECT)
response = rally.get('Story', fetch="FormattedID,Name,State",
project=BEEFIER_SUB_PROJECT,
projectScopeDown=False)
assert response.resultCount == 3
response = rally.get('Story', fetch="FormattedID,Name,State",
project=BEEFIER_SUB_PROJECT,
projectScopeUp=True,
projectScopeDown=False)
assert response.resultCount == 7
response = rally.get('Story', fetch="FormattedID,Name,State",
project=BEEFIER_SUB_PROJECT,
projectScopeDown=True)
assert response.resultCount == 5
response = rally.get('Story', fetch="FormattedID,Name,State",
project=BEEFIER_SUB_PROJECT,
projectScopeUp=False,
projectScopeDown=True)
assert response.resultCount == 5
response = rally.get('Story', fetch="FormattedID,Name,State",
project=BEEFIER_SUB_PROJECT,
projectScopeUp=True,
projectScopeDown=True)
assert response.resultCount == 9
# BOTTOM_PROJECT is a sub-project under BEEFIER_SUB_PROJECT
BOTTOM_PROJECT = 'Bristol Bay Barons'
response = rally.get('Story', fetch="FormattedID,Name,State",
project=BOTTOM_PROJECT)
assert response.resultCount == 2
response = rally.get('Story', fetch="FormattedID,Name,State",
project=BOTTOM_PROJECT,
projectScopeDown=True)
assert response.resultCount == 2
response = rally.get('Story', fetch="FormattedID,Name,State",
project=BOTTOM_PROJECT,
projectScopeUp=True, projectScopeDown=True)
assert response.resultCount == 9
示例15: RallyClient
# 需要导入模块: from pyral import Rally [as 别名]
# 或者: from pyral.Rally import setProject [as 别名]
class RallyClient(object):
def __init__(self, rally_server, username, password, oauth_key):
print "Initializing RallyClient\n"
self.rally_server = rally_server
rally_url = self.rally_server['url']
credentials = CredentialsFallback(self.rally_server, username, password).getCredentials()
self.rest_api = None
self.configure_proxy()
self.rest_api = Rally(URI(rally_url), credentials['username'], credentials['password'],
apikey=oauth_key if oauth_key else self.rally_server['oAuthKey'], verify_ssl_cert=False)
@staticmethod
def create_client(rally_server, username, password, oauth_key):
print "Executing create_client() in RallyClient class in RallyClient.py\n"
return RallyClient(rally_server, username, password, oauth_key)
def configure_proxy(self):
if self.rally_server['proxyHost']:
os.environ["HTTP_PROXY"] = "http://%s:%s" % (self.rally_server['proxyHost'], self.rally_server['proxyPort'])
os.environ["HTTPS_PROXY"] = "https://%s:%s" % (self.rally_server['proxyHost'], self.rally_server['proxyPort'])
if self.rally_server['proxyUsername']:
os.environ["HTTP_PROXY"] = "http://%s:%[email protected]%s:%s" % (
self.rally_server['proxyUsername'], self.rally_server['proxyPassword'],
self.rally_server['proxyHost'],
self.rally_server['proxyPort'])
os.environ["HTTPS_PROXY"] = "https://%s:%[email protected]%s:%s" % (
self.rally_server['proxyUsername'], self.rally_server['proxyPassword'],
self.rally_server['proxyHost'],
self.rally_server['proxyPort'])
def lookup_item_by_formatted_id(self, workspace, project, type, formatted_id):
self.rest_api.setWorkspace(workspace)
self.rest_api.setProject(project)
response = self.rest_api.get(type, fetch="ObjectID", query="FormattedID = %s" % formatted_id)
if not response.errors:
print("Total results: %d\n" % response.resultCount)
result = response.next()
return result.ObjectID
else:
print("The following errors occurred: ")
for err in response.errors:
print("\t" + err)
return None
def create_sub_item(self, workspace, project, properties, user_story_formatted_id, user_story_type, property_type,
item_type):
self.rest_api.setWorkspace(workspace)
self.rest_api.setProject(project)
story_ref = self.lookup_item_by_formatted_id(workspace, project, user_story_type, user_story_formatted_id)
property_dict = dict(ast.literal_eval(properties))
property_dict[property_type] = story_ref
return self.create_item(workspace, project, property_dict, item_type)
def create_item(self, workspace, project, properties, item_type):
self.rest_api.setWorkspace(workspace)
self.rest_api.setProject(project)
item_create_response = self.rest_api.put(item_type, properties)
print "Executed successful on Rally"
return item_create_response.FormattedID
def update_item(self, workspace, project, properties, item_formatted_id, item_type):
self.rest_api.setWorkspace(workspace)
self.rest_api.setProject(project)
item_object_id = self.lookup_item_by_formatted_id(workspace, project, item_type, item_formatted_id)
property_dict = dict(ast.literal_eval(properties))
property_dict["ObjectID"] = item_object_id
update_response = self.rest_api.post(item_type, property_dict)
print "Executed successful on Rally"
return update_response.FormattedID
def query(self, workspace, project, item_type, query, fetch="True", rollupdata=False):
self.rest_api.setWorkspace(workspace)
self.rest_api.setProject(project)
response = self.rest_api.get(item_type, fetch=fetch, query=query, projectScopeDown=rollupdata)
if not response.errors:
print("Total results: %d\n" % response.resultCount)
return response
else:
print("The following errors occurred: ")
for err in response.errors:
print("\t" + err)
return None
def get_user_object_id(self, owner_username=None, owner_name=None):
response = self.rest_api.getUserInfo(username=owner_username, name=owner_name)
return response[0].ObjectID