Пример #1
0
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.periscope')  # name of file for logging content

    for workspace in rally.getWorkspaces():
        print "%s %s" % (workspace.oid, workspace.Name)
        for project in rally.getProjects(workspace=workspace.Name):
            print "    %12.12s  %-36.36s   |%s|" % (project.oid, project.Name,
                                                    project.State)
        print ""
def test_ignore_defaults_use_good_workspace_none_project():
    from internal_rally_targets import APIKEY  # [email protected] key
    good_workspace = "Integrations Test"
    good_project = "Integrations Project"
    none_project = None

    rally = Rally(server=RALLY,
                  apikey=APIKEY,
                  workspace=good_workspace,
                  project=good_project,
                  server_ping=False)
    workspace = rally.getWorkspace()
    project = rally.getProject()
    assert (workspace.Name) == good_workspace
    assert (project.Name) == good_project

    problem = "The current Workspace '%s' does not contain a Project with the name of '%s'"
    problem_text = problem % (good_workspace, none_project)
    with py.test.raises(Exception) as excinfo:
        rally = Rally(server=RALLY,
                      apikey=APIKEY,
                      workspace=good_workspace,
                      project=none_project,
                      server_ping=False)
    actualErrVerbiage = excinfo.value.args[0]
    #print(actualErrVerbiage)
    assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
    assert actualErrVerbiage == problem_text
Пример #3
0
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 "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

    server, username, password, apikey, workspace, project = rallyWorkset(options)
    try:
        if apikey:
            rally = Rally(server, apikey=apikey, workspace=workspace, project=project)
        else:
            rally = Rally(server, user=username, password=password, workspace=workspace, project=project)
    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)
Пример #4
0
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)
Пример #5
0
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.history.showdefects")

    fields = "FormattedID,State,Name,Severity,Priority"
    criterion = 'State != Closed'

    response = rally.get('Defect',
                         fetch=fields,
                         query=criterion,
                         order="FormattedID",
                         pagesize=200,
                         limit=400)

    for defect in response:
        print("%-8.8s  %-52.52s  %s" %
              (defect.FormattedID, defect.Name, defect.State))

    print("-----------------------------------------------------------------")
    print(response.resultCount, "qualifying defects")
Пример #6
0
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:
        errout("ERROR: You must supply an entity name!\n")
        sys.exit(1)

    server, user, 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)

    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
Пример #7
0
def test_named_non_default_workspace_use_default_project():
    """
        Using valid Rally access credentials, connect specifying
        a valid non-default workspace but not specifying a project.
        Return status should be OK, the Rally instance's RallyContextHelper
        _inflated value should be 'narrow'

        Expanded this to incorporate two scenarios
            1) default project in default workspace is a valid project name
                in the named non-default workspace
            2) default project in default workspace is not a valid project name
                in the named non-default workspace
              
    """
    workspace = 'SCM Workspace'
    rally = Rally(server=TRIAL,
                  user=TRIAL_USER,
                  password=TRIAL_PSWD,
                  workspace=workspace,
                  warn=False)
    ai_proj = rally.getProject()
    assert str(ai_proj.Name) == 'Sample Project'
    assert rally._wpCacheStatus() == 'narrow'

    workspace = 'JIRA Testing'
    rally = Rally(server=TRIAL,
                  user=TRIAL_USER,
                  password=TRIAL_PSWD,
                  workspace=workspace,
                  warn=False)
    ai_proj = rally.getProject()
    assert str(
        ai_proj.Name) == 'GData Testing'  # is valid only in 'JIRA Testing'
    assert rally._wpCacheStatus() == 'narrow'
Пример #8
0
def test_non_rally_server():
    """
        Use a known valid server reachable on the Internet that 
        *doesn't* service Rally REST API requests. 
        Do the same test using default access credentials and known correct
        valid credentials to an existing Rally server.
        The attempt must generate an Exception
    """
    non_rally_server = 'www.irs.gov'
    #expectedErrMsg = "404 Target host: '%s' doesn't support the Rally WSAPI" % non_rally_server
    #timeoutMsg     = "Request timed out on attempt to reach %s" % non_rally_server
    #expectedErrMsg = "Response for request: .+//%s/.+ either was not JSON content or was an invalidly formed"
    expectedErrMsg = "Response for request: .*%s.* either was not JSON content or was an invalidly formed\/incomplete JSON structure" % non_rally_server
    with py.test.raises(RallyResponseError) as excinfo:
        rally = Rally(server=non_rally_server, timeout=5)
    actualErrVerbiage = excinfo.value.args[
        0]  # becuz Python2.6 deprecates message :-(
    #print("     expectedErrMsg: %s" % expectedErrMsg)
    #print("  actualErrVerbiage: %s" % actualErrVerbiage)
    assert excinfo.value.__class__.__name__ == 'RallyResponseError'
    ex_value_mo = re.search(expectedErrMsg, actualErrVerbiage)
    assert ex_value_mo is not None

    time.sleep(1)

    with py.test.raises(RallyResponseError) as excinfo:
        rally = Rally(server=non_rally_server,
                      user=TRIAL_USER,
                      password=TRIAL_PSWD,
                      timeout=5)
    actualErrVerbiage = excinfo.value.args[
        0]  # becuz Python2.6 deprecates message :-(
    assert excinfo.value.__class__.__name__ == 'RallyResponseError'
    time.sleep(1)
Пример #9
0
def test_ignore_defaults_use_good_workspace_none_project():
    good_workspace = "Integrations Test"
    good_project = "Integrations Project"
    none_project = None

    rally = Rally(server=TRIAL,
                  username=TRIAL_USER,
                  password=TRIAL_PSWD,
                  apikey=API_KEY,
                  workspace=good_workspace,
                  project=good_project,
                  server_ping=False)
    workspace = rally.getWorkspace()
    project = rally.getProject()
    assert (workspace.Name) == good_workspace
    assert (project.Name) == good_project

    problem = "The current Workspace '%s' does not contain a Project with the name of '%s'"
    problem_text = problem % (good_workspace, none_project)
    with py.test.raises(Exception) as excinfo:
        rally = Rally(server=TRIAL,
                      user=TRIAL_USER,
                      password=TRIAL_PSWD,
                      apikey=API_KEY,
                      workspace=good_workspace,
                      project=none_project,
                      server_ping=False)
    actualErrVerbiage = excinfo.value.args[0]
    #print("actualErrVerbiage")
    #print(actualErrVerbiage)
    assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
    assert actualErrVerbiage == problem_text
Пример #10
0
def test_nonexistent_server():
    """
        Using a known invalid server specification, obtain a Rally instance.
        An exception should be generated with verbiage about the hostname
        being non-existent or unreachable.
        Use the py.test context manager idiom to catch the generated exception
        and do the relevant assertions.

        Do the same test using default access credentials and known correct
        valid credentials to a non-existent server.
    """
    bogus_server = "bogus.notreally.bug"
    expectedErrMsg = "hostname '%s' non-existent or unreachable" % bogus_server
    #print expectedErrMsg
    with py.test.raises(RallyRESTAPIError) as excinfo:
        rally = Rally(server=bogus_server)
    actualErrVerbiage = excinfo.value.args[
        0]  # becuz Python2.6 deprecates message :-(
    #print actualErrVerbiage
    assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
    assert actualErrVerbiage == expectedErrMsg

    bogus_server = "bogus.notreally.bugu"
    expectedErrMsg = "hostname '%s' non-existent or unreachable" % bogus_server
    with py.test.raises(RallyRESTAPIError) as excinfo:
        rally = Rally(server=bogus_server,
                      user=PREVIEW_USER,
                      password=PREVIEW_PSWD)
    actualErrVerbiage = excinfo.value.args[
        0]  # becuz Python2.6 deprecates message :-(
    assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
    assert actualErrVerbiage == expectedErrMsg
Пример #11
0
def test_non_rally_server():
    """
        Use a known valid server reachable on the Internet that 
        *doesn't* service Rally REST API requests. 
        Do the same test using default access credentials and known correct
        valid credentials to an existing Rally server.
        The attempt must generate an Exception
        The status_code in the response must indicate a non-success condition.
    """
    non_rally_server = 'www.irs.gov'
    expectedErrMsg = "404 Target host: '%s' doesn't support the Rally WSAPI" % non_rally_server
    with py.test.raises(RallyRESTAPIError) as excinfo:
        rally = Rally(server=non_rally_server)
    actualErrVerbiage = excinfo.value.args[
        0]  # becuz Python2.6 deprecates message :-(
    assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
    assert actualErrVerbiage == expectedErrMsg

    with py.test.raises(RallyRESTAPIError) as excinfo:
        rally = Rally(server=non_rally_server,
                      user=PREVIEW_USER,
                      password=PREVIEW_PSWD)
    actualErrVerbiage = excinfo.value.args[
        0]  # becuz Python2.6 deprecates message :-(
    assert excinfo.value.__class__.__name__ == 'RallyRESTAPIError'
    assert actualErrVerbiage == expectedErrMsg
Пример #12
0
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=PREVIEW_USER,
                      password=PREVIEW_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
Пример #13
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args = [arg for arg in args if arg not in options]
    if len(args) != 2:
        errout(
            'ERROR: You must supply an Artifact identifier and an attachment file name'
        )
        errout(USAGE)
        sys.exit(1)
    target, attachment_file_name = args

    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.creattach')  # name of file you want logging to go to

    artifact = validateTarget(rally, target)

    me = rally.getUserInfo(username=username).pop(0)
    #print "%s user oid: %s" % (username, me.oid)

    att = rally.addAttachment(artifact, attachment_file_name)
    print("created Attachment: %s for %s" % (attachment_file_name, target))
Пример #14
0
def login():
	global rally
	global server_name
	global debug
	global user_name
	global password
	global workspace
	global project
	global workspace_names
	global rally_server
	global api_key
	global exe_path

	user_name 	= ""
	password 	= ""
	workspace 	= ""
	project 	= ""
	api_key 	= ""
	rally_server 	= ""
	
	read_config()

        try:
                if api_key == "":
			print "Login/password connection"
			rally = Rally(rally_server, user_name, password, workspace=workspace, project=project)
		if api_key != "":
			print "API connection"
			rally = Rally(rally_server, apikey=api_key, workspace=workspace, project=project)
        except Exception, details:
                print ("Error logging in")
		send_email_error("Error logging in")
                close_pid()
                sys.exit(1)
Пример #15
0
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.item')  # name of file you want logging to go to

    if len(args) != 2:
        errout(USAGE)
        sys.exit(2)
    entity_name, ident = args
    if entity_name in STORY_ALIASES:
        entity_name = 'HierarchicalRequirement'

    mo = OID_PATT.match(ident)
    if mo:
        ident_query = 'ObjectID = %s' % ident
    else:
        mo = FORMATTED_ID_PATT.match(ident)
        if mo:
            ident_query = 'FormattedID = "%s"' % ident
        else:
            errout('ERROR: Unable to determine ident scheme for %s\n' % ident)
            sys.exit(3)

    response = rally.get(entity_name,
                         fetch=True,
                         query=ident_query,
                         workspace=workspace,
                         project=project)

    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 item found for %s %s\n' % (entity_name, ident))
        sys.exit(4)
    elif response.resultCount > 1:
        errout('WARNING: more than 1 item returned matching your criteria\n')
        sys.exit(5)

    for item in response:
        print(item.details())
Пример #16
0
def main(args):
    options = [opt for opt in args if opt.startswith('--')]
    args = [arg for arg in args if arg not in options]
    if len(args) != 1:
        errout(USAGE)
        sys.exit(1)
    storyID = args[0]

    server, user, 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.history.crtask")

    # For a task: Workspace, Project, WorkProduct, Name, State, TaskIndex are required;
    # Workspace cannot be specified in the JSON, it defaults to
    # the logged in account's Workspace setting
    # Project and WorkProduct must be object refs to relevant Rally Entity instances.
    # In this example the WorkProduct is a UserStory (HierarchicalRequirement).

    target_project = rally.getProject()
    target_story = rally.get('UserStory',
                             query='FormattedID = %s' % storyID,
                             instance=True)

    info = {
        "Project":
        target_project.ref,
        "WorkProduct":
        target_story.ref,
        "Name":
        "BigTaters",
        "State":
        "Defined",
        "TaskIndex":
        1,
        "Description":
        "Fly to Chile next week to investigate the home of potatoes.  Find the absolute gigantoidist spuds and bring home the eyes to Idaho.  Plant, water, wonder, harvest, wash, slice, plunge in and out of hot oil, drain and enjoy! Repeat as needed.",
        "Estimate":
        62.0,
        "Actuals":
        1.0,
        "ToDo":
        61.0,
        "Notes":
        "I have really only done some daydreaming wrt this task.  Sorry Jane, I knew you had big plans for Frankie's blowout BBQ next month, but the honeycomb harvest project is taking all my time."
    }

    print "Creating Task ..."
    task = rally.put('Task', info)
    print "Created  Task: %s   OID: %s" % (task.FormattedID, task.oid)
Пример #17
0
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):
            fields = line.split(',')
            if len(fields) != 3:
                raise Exception('Line #%d has invalid number of fields: %s' % (ix+1, repr(fields)))
            tcr_info.append([field.strip() for field in fields])
    except Exception:
        errout("ERROR: reading file '%s'.  Check the permissions or the content format for correctness." % tcr_info_filename)
        errout(USAGE)
        sys.exit(2)

    test_case = rally.get('TestCase', query="FormattedID = %s" % test_case_id,
                          workspace=workspace, project=None, instance=True)
    if not test_case or hasattr(test_case, 'resultCount'):
        print "Sorry, unable to find a TestCase with a FormattedID of %s in the %s workspace" % \
              (test_case_id, workspace)
        sys.exit(3)

    wksp = rally.getWorkspace()

    for build, run_date, verdict in tcr_info:
        tcr_data = { "Workspace" : wksp.ref,
                     "TestCase"  : test_case.ref,
                     "Build"     : build,
                     "Date"      : run_date,
                     "Verdict"   : verdict
                   }
        try:
            tcr = rally.create('TestCaseResult', tcr_data)
        except RallyRESTAPIError, details:
            sys.stderr.write('ERROR: %s \n' % details)
            sys.exit(4)
        
        print "Created  TestCaseResult OID: %s  TestCase: %s  Build: %s  Date: %s  Verdict: %s" % \
               (tcr.oid, test_case.FormattedID, tcr.Build, tcr.Date, tcr.Verdict)
Пример #18
0
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.item')  # name of file you want logging to go to

    retdata = getPreCommit()
    if retdata != 0:
        print("Return Value: " + retdata)

    #entity_name, ident = args
    entity_name = 'Defect'

    ident_query = 'FormattedID = "%s"' % retdata

    response = rally.get(entity_name,
                         fetch=True,
                         query=ident_query,
                         workspace=workspace,
                         project=project)

    if response.errors:
        errout("Request could not be successfully serviced, error code: %d\n" %
               response.status_code)
        errout("\n".join(response.errors))
        retFlag = 0

    if response.resultCount == 0:
        errout('No item found for %s %s\n' % (entity_name, retdata))
        retFlag = 0
    elif response.resultCount > 1:
        errout('WARNING: more than 1 item returned matching your criteria\n')
        retFlag = 0
    else:
        print("Time to commit")
        retFlag = 1

    if retFlag == 1:
        print("Commit here")
Пример #19
0
def main(args):
    options = [opt for opt in sys.argv[1:] if opt.startswith('--')]
    args    = [arg for arg in sys.argv[1:] if arg not in options]
    server, username, password, apikey, workspace, project = rallyWorkset(options)

    # if len(args) < 2:
    #     errout(USAGE)
    #     sys.exit(2)
    if "-h" in args or "--help" in args or len(args) < 1:
        parser = argparse.ArgumentParser()
        parser.add_argument("[Please input 2 Parameters]", help="This script is to Update a given Defect")
        parser.add_argument("userStoryID, PromotedImpactedEnvironment",
                            help="Please provide required Defect attributes to update")
        result = parser.parse_args()
        sys.exit(2)
    # parser = argparse.ArgumentParser()
    # parser.add_argument("Description", help="This script is to Update a given Defect")
    # parser.add_argument("Update Defect",
    #                     help="Please provide required Defect attributes to update")
    # args = parser.parse_args()

    if apikey:
            rally = Rally(server, apikey=apikey, workspace=workspace, project=project)
    else:
            rally = Rally(server, user=username, password=password, workspace=workspace, project=project)

    projects = rally.getProjects(workspace)
    entity_name = 'UserStory'

    userStoryID, PromotedImpactedEnvironment = args[:2]

    userStory_data = {"FormattedID": userStoryID,
                      "PromotedImpactedEnvironment": PromotedImpactedEnvironment
                     }

    ident_query = 'FormattedID = "%s"' % userStoryID

    try:
        for proj in projects:
            # print("    %12.12s  %s" % (proj.oid, proj.Name))
            response = rally.get(entity_name, fetch=True, query=ident_query,
                                 workspace=workspace, project=proj.Name)
            if response.resultCount > 0:
                print("Workspace Name: %s , Project Name: %s , Entity Name: %s , User Story Id: %s" %(workspace, proj.Name, entity_name, userStoryID))
                userStory = rally.update(entity_name, userStory_data, project=proj.Name)
                break

    except Exception:
        sys.stderr.write('ERROR: %s \n'+errout)
        sys.exit(1)

    print("\nUser Story %s updated with following attributes:" % userStoryID)
    print("FormattedID: " + userStoryID)
    print("PromotedImpactedEnvironment: " + PromotedImpactedEnvironment+"\n")
Пример #20
0
def test_get_default_workspace():
    """
        Using a known valid Rally server and known valid access credentials,
        and specifying the default workspace and project, verify that
        calling the getWorkspace method returns info for the default
        workspace.
    """
    rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD)
    workspace = rally.getWorkspace()
    assert workspace.Name == DEFAULT_WORKSPACE
    rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD, workspace=DEFAULT_WORKSPACE)
    workspace = rally.getWorkspace()
    assert workspace.Name == DEFAULT_WORKSPACE
Пример #21
0
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)
    print(f'server: {server}')
    print(f'apikey: {apikey}')
    print(f'workspace: {workspace}')
    print(f'project  : {project}')
    if apikey:
        #rally = Rally(server, apikey=apikey, workspace=workspace, project=project)
        rally = Rally(server, apikey=apikey, workspace=workspace)
    else:
        #rally = Rally(server, user=username, password=password, workspace=workspace, project=project)
        rally = Rally(server, user=username, password=password, workspace=workspace)

    rally.enableLogging('rally.hist.artifact') # name of file you want logging to go to

    if len(args) != 1:
        errout(USAGE)
        sys.exit(2)
    ident = args.pop(0)

    mo = FORMATTED_ID_PATT.match(ident)
    if mo:
        ident_query = 'FormattedID = "%s"' % ident
    else:
        errout('ERROR: Unable to detect a valid Rally FormattedID in your arg: %s\n' % ident)
        sys.exit(3)
    mo = re.match(r'^(?P<art_abbrev>DE|S|US|TA|TC|F|I|T)\d+$', ident)
    if not mo:
        errout('ERROR: Unable to extract a valid Rally artifact type abbrev in %s' % ident)
        sys.exit(4)
    art_abbrev = mo.group('art_abbrev') 
    entity_name = ARTIFACT_TYPE[art_abbrev]

    response = rally.get(entity_name, fetch=True, query=ident_query, workspace=workspace)

    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 item found for %s %s\n' % (entity_name, ident))
        sys.exit(4)
    elif response.resultCount > 1:
        errout('WARNING: more than 1 item returned matching your criteria\n')
        sys.exit(5)

    for item in response:
        print(item.details())
Пример #22
0
    def __init__(self, basic_auth, api_key, project, workspace, logger, is_testing):
        """
        Instantiate and return a Rally client pointed at https://rally1.rallydev.com.
        """
        self.log = logger
        self.is_testing = is_testing
        # logger.info('::: ')
        # logger.info('::: api_key: '+str(api_key))

        if api_key:
            logger.info('::: authenticate via API key')
            self.client = Rally(RALLY_SERVER, apikey=api_key, workspace=workspace, project=project)
        else:
            logger.info('::: authenticate via user CREDS')
            self.client = Rally(RALLY_SERVER, user=basic_auth[0], password=basic_auth[1], workspace=workspace, project=project)
Пример #23
0
def test_initial_non_default_workspace_as_isolated():
    rally = Rally(server=AGICEN,
                  user=AGICEN_USER,
                  password=AGICEN_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
Пример #24
0
def initRally(cmdLineOptions):
	requiredOptions = {'rallyServer','rallyUser','rallyPassword'}
	print 'Setting up Rally (pyral v{version})...'.format(version = pyral.__version__)
	if not requiredOptions.issubset(cmdLineOptions):
		print "ERROR: One of more of the required Rally options ({}) missing.".format(requiredOptions)
		sys.exit()
	return Rally(cmdLineOptions['rallyServer'], cmdLineOptions['rallyUser'], cmdLineOptions['rallyPassword'])
Пример #25
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)
    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
Пример #26
0
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
Пример #27
0
def test_mep_project_in_request_payload():
    """
        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.
        Assemble a payload dict to be used in creating a BuildDefinition item
        that uses a m-e-p Project value for the Project attribute.
        Issue the request to create the BuildDefinition item.
        The result should be the creation of the BuildDefinition item
        for which the Project attribute has a ref to the targeted m-e-p Project.
    """
    rally = Rally(server=TRIAL,
                  user=YETI_USER,
                  password=YETI_PSWD,
                  workspace=BOONDOCKS_WORKSPACE,
                  project=BOONDOCKS_PROJECT)
    workspace = rally.getWorkspace()
    dd_project = rally.getProject(DEEP_DUPE)
    info = {
        'Name': 'Throckmorton Nunnigan',
        'Description': 'A completely artificial sweetener',
        'Workspace': workspace._ref,
        'Project': dd_project._ref
    }

    build_defn = rally.create('BuildDefinition', info)
    assert build_defn.Project._ref == dd_project._ref
def test_defects_revision_history():
    """
        Using a known valid Rally server and known valid access credentials,
        issue a simple query (no qualifying criteria) against a Rally entity
        (Defect) known to have an attribute (RevisionHistory) that has an
        attribute (Revisions) that is a Rally collections reference.
        This test demonstrates the lazy-evaluation of non first-level attributes.
        Ultimately, the attributes deeper than the first level must be obtained
        and have their attributes filled out completely (_hydrated == True).
    """
    rally = Rally(server=TRIAL, user=TRIAL_USER, password=TRIAL_PSWD)
    response = rally.get('Defect', fetch=True, limit=10)

    defect1 = response.next()
    defect2 = response.next()
    assert defect1.oid != defect2.oid

    d1_revs = defect1.RevisionHistory.Revisions
    d2_revs = defect2.RevisionHistory.Revisions

    assert type(d1_revs) == list
    assert type(d2_revs) == list

    d1_rev1 = d1_revs.pop(
    )  # now the revs are in stack order, newest first, original the last
    d2_rev1 = d2_revs.pop()  # ditto

    assert d1_rev1.RevisionNumber == 0
    assert d2_rev1.RevisionNumber == 0

    assert d1_rev1.Description != "" and len(d1_rev1.Description) > 0
    assert d2_rev1.Description != "" and len(d2_rev1.Description) > 0

    assert d1_rev1._hydrated == True
    assert d2_rev1._hydrated == True
Пример #29
0
def test_default_workspace_with_set_non_default_workspace_and_project_context(
):
    rally = Rally(server=AGICEN,
                  user=AGICEN_USER,
                  password=AGICEN_PSWD,
                  workspace=DEFAULT_WORKSPACE)
    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')
    #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
Пример #30
0
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