Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_three_condition_query_in_list():
"""
Using a known valid Rally server and known valid access credentials,
issue a query with three qualifying conditions against a Rally entity
(Defect) known to exist for which the qualifying criterion should return
one or more Defects. The qualifying criterion is a list that contains
three condition strings, each condition string does _not_ have any
surrounding paren chars.
"""
rally = Rally(server=AGICEN, user=AGICEN_USER, password=AGICEN_PSWD)
#qualifiers = ["State = Submitted", "FormattedID != DE100", "Owner.UserName != horsefeathers"]
qualifiers = ["State = Submitted", "FormattedID != DE100", "Severity != UltraMegaHurt"]
response = rally.get('Defect', fetch=True, query=qualifiers, limit=10)
assert response.resultCount > 0
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=AGICEN, user=AGICEN_USER, password=AGICEN_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
def test_set_default_workspace_non_default_project_context():
rally = Rally(server=AGICEN, user=AGICEN_USER, password=AGICEN_PSWD,
workspace=DEFAULT_WORKSPACE,
project=NON_DEFAULT_PROJECT)
workspace = rally.getWorkspace()
assert workspace.Name == DEFAULT_WORKSPACE
project = rally.getProject()
assert project.Name == NON_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
def test_getAllowedValues_query():
"""
Using a known valid Rally server and known valid access credentials,
request the allowed value information for the State field of the Defect entity and
request the allowed value information for the PrimaryColor field of the Defect entity.
"""
rally = Rally(server=AGICEN, user=AGICEN_USER, password=AGICEN_PSWD)
avs = rally.getAllowedValues('Defect', 'State')
assert len(avs) > 0
assert len(avs) >= 4
assert 'Open' in avs
assert 'Closed' in avs
avs = rally.getAllowedValues('Defect', 'PrimaryColor')
assert len(avs) > 0
assert len(avs) >= 6 and len(avs) <= 8
assert 'Red' in avs
assert 'Magenta' in avs
assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
assert expectedErrMsg in actualErrVerbiage
#print "detected invalid user, blank password condition"
time.sleep(1)
with py.test.raises(RallyRESTAPIError) as excinfo:
rally = Rally(server=AGICEN, user="guest", password="doofus")
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 expectedErrMsg in actualErrVerbiage
#print "detected invalid user, invalid password condition"
time.sleep(1)
with py.test.raises(RallyRESTAPIError) as excinfo:
rally = Rally(server=AGICEN, user="guest")
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 expectedErrMsg in actualErrVerbiage
#print "detected invalid user, missing password condition"
def test_basic_connection_with_bad_api_key():
"""
Using a known valid Rally server and bogus API Key value,
issue a simple query request against a known valid Rally target.
The result should be that the attempt raises an exception.
"""
BOGUS_API_KEY = "_ABC123DEF456GHI789JKL012MNO345PQR678STUVZ"
expectedErrMsg = 'Invalid credentials'
with py.test.raises(RallyRESTAPIError) as excinfo:
rally = Rally(PROD, "zooka@fluffernetter.com", "manict0X0", apikey=BOGUS_API_KEY)
actualErrVerbiage = excinfo.value.args[0]
assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
assert expectedErrMsg == actualErrVerbiage
time.sleep(1)
def test_four_ored_conditions_in_parrened_string():
"""
Take a user query with OR conditions in which the parenneg groups are
already supplied in AgileCentral conformant "binary" condition style
"""
rally = Rally(server=AGICEN, user=AGICEN_USER, password=AGICEN_PSWD,
workspace=BOONDOCKS_WORKSPACE, project=BOONDOCKS_PROJECT)
qualifiers = '((((Name = "Brazen%20Milliwogs") OR (Name = "Jenkins")) OR (Name = "Refusnik")) OR (Name = "Salamandra"))'
response = rally.get('Project', fetch=True, query=qualifiers, limit=10)
assert response.resultCount > 0
projects = [project for project in response]
#print([project.Name for project in projects])
assert response.resultCount == 2 # Only Jenkins and Salamandra exist or or accessible to the accessing account
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)
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.add_tcrs")
if len(args) < 2:
errout(USAGE)
sys.exit(1)
test_case_id, tcr_info_filename = args
if not os.path.exists(tcr_info_filename):
errout("ERROR: file argument '%s' does not exist. Respecify using corrent name or path\n" % tcr_info_filename)
errout(USAGE)
sys.exit(2)
try:
with open(tcr_info_filename, 'r') as tcif:
content = tcif.readlines()
tcr_info = []
# each line must have Build, Date, Verdict
for ix, line in enumerate(content):
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)
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)
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.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)