def test_update_several_custom_fields(): """ create a JIRA issue and update several custom fields """ #jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) jp = JiraProxy(GOOD_VANILLA_ONDEMAND_CONFIG) work_item = { "Summary": "potash deposit extraction shifting towards foreign suppliers", #"Reporter" : GOOD_VANILLA_SERVER_CONFIG['user'], "Assignee": JIRA_DEV_USER, "Priority": "Lowest", "Severity": "Cosmetic", "RallyID": 123453532, "Support Review Date": '2021-12-14T11:28:45', 'RallyLink': 'https://rally1.rallydev.com/slm/detail/3243432' } issue_key = jp.createIssue(OD_PROJECT_KEY_1, "Bug", work_item) issue = jp.getIssue(issue_key) issue.RallyItem = "S879324" issue.RallyID = 9883990192 issue["Support Review Date"] = "2021-02-13T15:43:30" assert jp.updateIssue(issue) == True issue = jp.getIssue(issue_key) assert issue.RallyItem == "S879324" assert issue.RallyID == 9883990192 assert '2021-02-13T' in issue["Support Review Date"] assert jp.deleteIssue(issue_key)
def test_update_with_non_default_priority_and_versions_components_fields(): """ create a JIRA issue and then update it with non-default priority value along with version and components values """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = { 'Summary': "stuck vontracular relay caused moribundal" " shudders while accelerative mode shunt activated", 'Reporter': GOOD_VANILLA_SERVER_CONFIG['user'], 'Assignee': JIRA_DEV_USER, 'Description': "ice blocks whizzed dangerously close to several portholes", 'Due Date': "2016-02-20", 'Environment': "Screaming 60's", 'Affects Version/s': "cherry", #'Fix Version/s' : "lemon", #'Fix Version/s' : "cherry, peach", #'Components' : "Routing" # not required, must be in list of allowedValues, } issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) issue = jp.getIssue(issue_key) issue["Priority"] = "Highest" issue["Affects Version/s"] = "vanilla,peach" jp.updateIssue(issue) issue = jp.getIssue(issue_key) assert issue.Priority == "Highest" assert set(issue["Affects Version/s"]) == set(["vanilla", "peach"]) assert jp.deleteIssue(issue_key)
def test_update_original_estimate_field(): """ create an issue without originalEstimate and later update it with originalEstimate """ original_estimate = '2d 4h' remaining_estimate = '2d 6h' jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = {"Summary": "Another Blustery Day"} issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) issue = jp.getIssue(issue_key) assert issue['Time Tracking'] == {} issue['Time Tracking'] = {'originalEstimate': original_estimate} # don't try this: # issue['Time Tracking']['originalEstimate'] = original_estimate # It will not work and you will be sad and you will gnash your teeth... assert jp.updateIssue(issue) == True issueAgain = jp.getIssue(issue_key) assert issueAgain['Time Tracking']['originalEstimate'] == original_estimate assert issueAgain['Time Tracking'][ 'remainingEstimate'] == original_estimate # you have to set the whole 'Time Tracking' item so that the originalEstimate is not overwritten issue['Time Tracking'] = { 'originalEstimate': original_estimate, 'remainingEstimate': remaining_estimate } assert jp.updateIssue(issue) == True issueAgain = jp.getIssue(issue_key) assert issueAgain['Time Tracking']['originalEstimate'] == original_estimate assert issueAgain['Time Tracking'][ 'remainingEstimate'] == remaining_estimate assert jp.deleteIssue(issue_key)
def test_transition_new_issue_to_resolved_state_with_reso_in_restrictive_workflow(): """ transition a new issue to the Resolved state with a resolution in restrictive workflow """ jp = JiraProxy(GOOD_VANILLA_ONDEMAND_CONFIG) work_item = {"Summary" : "Daytime TV spokesdroid says Be Sassy!"} issue_key = jp.createIssue(PROJECT_KEY_4, "Bug", work_item) jp.transitionIssueState(issue_key, "Resolved", "Cannot Reproduce") issue = jp.getIssue(issue_key) assert issue.Status == "Resolved" assert issue.Resolution == "Cannot Reproduce" jp.transitionIssueState(issue_key, "Reopened") issue = jp.getIssue(issue_key) assert issue.Status == "Reopened" jp.transitionIssueState(issue_key, "Closed", "Fixed") # for ON_DEMAND issue = jp.getIssue(issue_key) assert issue.Status == "Closed" jp.transitionIssueState(issue_key, "Reopened") issue = jp.getIssue(issue_key) assert issue.Status == "Reopened" jp.transitionIssueState(issue_key, "Resolved") issue = jp.getIssue(issue_key) assert issue.Status == "Resolved" assert jp.deleteIssue(issue_key)
def test_transition_bug_to_resolved_state(): """ transition an ON_DEMAND instance Bug in the 'RW' project to Resolved """ """ jp = JiraProxy(GOOD_VANILLA_SERVER_DEV_USER_CONFIG) work_item = {"Summary" : "Benkmeister Fullmore writez stuff"} issue_key = jp.createIssue(PROJECT_KEY_4, "Bug", work_item) jp.transitionIssueState(issue_key, "Released", "Done" ) issue = jp.getIssue(issue_key) assert issue.Status == "Released" assert issue.Resolution == "Done" assert jp.deleteIssue(issue_key) """ jp = JiraProxy(GOOD_VANILLA_ONDEMAND_CONFIG) work_item = {"Summary" : "Benkmeister Fullmore writez stuff"} issue_key = jp.createIssue(PROJECT_KEY_4, "Bug", work_item) jp.transitionIssueState(issue_key, "Resolved", "Done" ) issue = jp.getIssue(issue_key) assert issue.Status == "Resolved" assert issue.Resolution == "Done" assert jp.deleteIssue(issue_key)
def test_get_comments_list_for_specific_issue_id(): """ get a list of comments with the getComments method given an issue id """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) target_issue_key = f'{PROJECT_KEY_1}-2' target_issue = jp.getIssue(target_issue_key) assert target_issue comments = jp.getComments(target_issue_key) for comment in comments: cmt_id = comment['id'] status, result, errors = jp.jira_comm.deleteRequest( f'issue/{target_issue_key}/comment/{cmt_id}') if errors: raise Exception('Unable to delete a comment from the target issue') comments = jp.getComments(target_issue_key) assert len(comments) == 0 test_comment = 'A comment to be tested.' jp.addComment(target_issue_key, test_comment) comments = jp.getComments(target_issue_key) assert len(comments) == 1 assert comments[0]["body"] == test_comment another_comment = 'Winds slips swiftly through the leafless branches' jp.addComment(target_issue_key, another_comment) comments = jp.getComments(target_issue_key) assert len(comments) == 2 assert comments[1]["body"] == another_comment
def test_transition_previously_created_new_feature_issue_to_other_states_with_a_resolution_for_appropriate_states( ): """ transition a newly created issue through many states """ jp = JiraProxy(VANILLA_SERVER_REGULAR_USER_CONFIG) status_items = jp.getStatuses(VANILLA_SERVER_REGULAR_USER_CONFIG) #print("\nStatus values for the NFI project") #for status in status_items: # print(f'... {status}') nf_item = jp.getIssue(STATIC_NEW_FEATURE_ITEM) #print(f"Current state: {nf_item.Status} Resolution: |{nf_item.Resolution}|") transitions = jp.getTransitions(nf_item.key) #for next_state, trans_info in transitions.items(): # print(next_state, trans_info) #print(f"\n {nf_item.key} Status Transitions:") for new_state in expected_results: #print(f'Updating current status {nf_item.Status} to {new_state}') if nf_item.Status == new_state: #print(f'... skipping status update, new_status same as current status {nf_item.Status}') continue nf_item = jp.transitionIssueState(nf_item.key, new_state, resolution=None) #print(f'... transitioned Issue.Status is now {nf_item.Status}') assert nf_item.Status == new_state
def test_create_story_with_original_estimate_field_set(): """ create a new JIRA Story with the OriginalEstimate field value set """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = { "Summary": 'Units of hard labor required to spring ex-presidential candidates from prison', # "timetracking" : {'originalEstimate' : '4m 2w 3d'} } "timetracking": { 'originalEstimate': '6w 2d 4h' } } issue_key = jp.createIssue(PROJECT_KEY_1, "Story", work_item) issue_key_patt = re.compile(f'^{PROJECT_KEY_1}-\\d+') assert issue_key_patt.match(issue_key) story_issue = jp.getIssue(issue_key) #print( story_issue.attributes ) #print( "Issue: #{issue_key} Summary: #{story_issue['Summary']}" ) #print( "timeestimate: #{story_issue.timeestimate}" ) #print( "timeoriginalestimate: #{story_issue.timeoriginalestimate}" ) #print( "---------------------------------------------" ) #print( "Time Tracking: #{story_issue['Time Tracking']}" ) #print( "---------------------------------------------" ) #print( "Time Tracking: -> originalEstimate #{story_issue['Time Tracking']['originalEstimate']}" ) assert story_issue['Time Tracking']['originalEstimate'] == "6w 2d 4h" assert jp.deleteIssue(issue_key)
def main(args): jira = JiraProxy(REG_USER_CONFIG) target_issue = jira.getIssue(JIRA_ISSUE_KEY) attachments = jira.getIssueAttachmentsInfo(JIRA_ISSUE_KEY) textfile = '../test/attachments/testattachment.txt' txtf_info = {'filename' : 'uvular.txt', 'file_content' : Path(textfile).read_bytes(), 'mimetype' : "text/plain" } jpeg_file = '../test/attachments/earthjello.jpeg' imgf_info = {'filename' : 'ragnarok.jpeg', 'file_content' : Path(jpeg_file).read_bytes(), 'mimetype' : "image/jpeg" } attachments = [txtf_info, imgf_info] result = jira.addAttachmentsToIssue(target_issue.key, attachments) assert result['uvular.txt']["added"] == True assert result['ragnarok.jpeg']["added"] == True
def test_update_custom_datetime_field(): """ get a bug from a getIssue call and update custom datetime field """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) target_item = f'{PROJECT_KEY_1}-4' jira_issue = jp.getIssue(target_item) assert jira_issue.key == target_item #the timestamp value for 'Support Review Date' needs to be in yy-mm-ddTHH:MM:SS.lll format past_timestamp = datetime.now() - timedelta(2) # minus two days from today jira_issue['Support Review Date'] = past_timestamp.isoformat( timespec='milliseconds') #print(f"past_timestamp: {past_timestamp}") assert jp.updateIssue(jira_issue) == True same_jira_issue = jp.getIssue(target_item) assert same_jira_issue['Support Review Date'] != None
def main(args): jira = JiraProxy(REG_USER_CONFIG) issue = jira.getIssue(ISSUE_KEY) display_names = issue.attributeDisplayNames() for name in display_names: print(name)
def test_transition_issue_to_done_state_and_wont_do_resolution(): """ transition issue to Done status and Won't Do resolution """ jp = JiraProxy(GOOD_VANILLA_SERVER_DEV_USER_CONFIG) work_item = {"Summary" : "Roller Coaster assembly point", "Resolution" : "Won't Do"} issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) jp.transitionIssueState(issue_key,"Done" ) issue = jp.getIssue(issue_key) assert issue.Status == "Done" assert issue.Resolution == "Done" issue.Resolution = "Won't Do" success = jp.updateIssue(issue) if success: issue = jp.getIssue(issue.key) assert issue.Resolution == "Won't Do" assert jp.deleteIssue(issue_key)
def test_update_rallyid_and_rallyitem_fields(): """ create a JiraIssue and update the RallyID and RallyItem fields """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = {"Summary": "for custom field updating purposes"} issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) issue = jp.getIssue(issue_key) issue.RallyID = 45981298 issue.RallyItem = "DE8822" assert jp.updateIssue(issue) == True issueAgain = jp.getIssue(issue_key) assert issueAgain.RallyID == 45981298 assert issueAgain.RallyItem == "DE8822" assert jp.deleteIssue(issue_key)
def test_create_bug_with_multiple_affects_version_values(): """ create a new Jira Bug with a multiple valid Affects Version/s values """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) item_data = {'Summary' : 'Narrow morbid futons for sales', 'Affects Version/s' : 'apple,lime' } issue_key = jp.createIssue(PROJECT_KEY_1, 'Bug', item_data) issue = jp.getIssue(issue_key) assert set(issue['Affects Version/s']) == set(['apple', 'lime'])
def test_create_bug_with_target_release_value(): """ create a new Jira Bug with a valid Target Release value """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) item_data = {'Summary' : 'Archery nomads on a rampage for doilies', 'Target Release' : 'lime' } issue_key = jp.createIssue(PROJECT_KEY_1, 'Bug', item_data) issue = jp.getIssue(issue_key) assert issue['Target Release'] == 'lime'
def test_transition_new_issue_to_Closed_state_without_resolution_in_restrictive_workflow(): """ transition a new issue to Closed state without a resolution in restrictive workflow """ jp = JiraProxy(GOOD_VANILLA_ONDEMAND_CONFIG) work_item = {"Summary" : "Your life is an insult to the galaxy", "Priority" : "Highest"} issue_key = jp.createIssue(PROJECT_KEY_4, "Bug", work_item) jp.transitionIssueState(issue_key, "Closed") issue = jp.getIssue(issue_key) assert issue.Status == "Closed" assert jp.deleteIssue(issue_key)
def test_update_resolution_with_valid_value(): """ create a JIRA issue and update the Resolution field when Jira is configured to do so """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = {"Summary": "Rally Sunny Day"} issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) issue = jp.getIssue(issue_key) assert issue.Resolution is None issue.Summary = "Rally Rainy Day" issue.Resolution = "Won't Do" assert jp.updateIssue(issue) == True issueAgain = jp.getIssue(issue_key) assert issueAgain.Summary == "Rally Rainy Day" assert issueAgain.Resolution == "Won't Do" assert jp.deleteIssue(issue_key)
def test_create_bug_with_single_affects_version_value(): """ create a new Jira Bug with a single valid Affects Version/s value """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) item_data = {'Summary' : 'Narrow morbid futons for sales', 'Affects Version/s' : 'orange' } issue_key = jp.createIssue(PROJECT_KEY_1, 'Bug', item_data) issue = jp.getIssue(issue_key) assert issue['Affects Version/s'] == ['orange']
def test_update_the_issue_type_using_display_name(): """ allows update of Jira issue type using the display name Issue Type """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = { "Summary": "peltonen skis were the rage in the late 80's and early 90's", "Reporter": GOOD_VANILLA_SERVER_CONFIG['user'], "Assignee": JIRA_DEV_USER, "Priority": "Highest", } issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) issue = jp.getIssue(issue_key) issue.Summary = "factory of stuff" issue["Issue Type"] = "Story" assert jp.updateIssue(issue) == True upd_issue = jp.getIssue(issue_key) assert upd_issue["Issue Type"] == "Story" assert jp.deleteIssue(issue_key)
def test_resolution_attribute_is_editable_for_issue_in_resolved_state(): """ Resolution attribute can be edited for an issue in the Resolved state """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = {"Summary" : "Roller Coaster scream tester"} issue_key = jp.createIssue(PROJECT_KEY_2, "Bug", work_item) issue = jp.getIssue(issue_key) issue.Status= "Done" issue.Resolution = "Done" jp.updateIssue(issue) assert issue.Status == "Done" #assert issue.Resolution == "Won't Do" assert issue.Resolution == "Done" issue["Resolution"] = "Won't Do" jp.updateIssue(issue) issue = jp.getIssue(issue_key) assert issue.Resolution == "Won't Do" assert jp.deleteIssue(issue_key)
def test_transition_newly_created_issue_to_resolved_state_with_a_resolution(): """ transition a newly created issue to the Resolved state with a resolution """ jp = JiraProxy(GOOD_VANILLA_SERVER_DEV_USER_CONFIG) work_item = {"Summary" : "Roller Coaster assembly point"} issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) jp.transitionIssueState(issue_key, "Done") issue = jp.getIssue(issue_key) assert issue.Status == "Done" assert issue.Resolution == "Done" assert jp.deleteIssue(issue_key)
def test_transition_new_issue_to_resolved_state_without_resolution_in_restrictive_workflow(): """ transition a new issue to Resolved state without a resolution in restrictive workflow """ jp = JiraProxy(GOOD_VANILLA_ONDEMAND_CONFIG) work_item = {"Summary" : "Don't be sassy with me!"} issue_key = jp.createIssue(PROJECT_KEY_4, "Bug", work_item) jp.transitionIssueState(issue_key, "Resolved") issue = jp.getIssue(issue_key) assert issue.Status == "Resolved" assert issue.Resolution is None assert jp.deleteIssue(issue_key)
def test_transition_newly_created_issue_to_closed_state_in_restricted_workflow(): """ transition a newly created issue to the Closed state in restricted workflow """ jp = JiraProxy(GOOD_VANILLA_ONDEMAND_CONFIG) work_item = {"Summary" : "Hand Grenades and horseshoes"} issue_key = jp.createIssue(PROJECT_KEY_4, "Bug", work_item) jp.transitionIssueState(issue_key, "Closed", "Won't Do") issue = jp.getIssue(issue_key) assert issue.Status == "Closed" assert issue.Resolution == "Won't Do" assert jp.deleteIssue(issue_key)
def test_update_summary_desc_priority_assignee_fields(): """ create a minimal JIRA issue and update the Summary, Description, Priority and Assignee fields """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = {"Summary": "nothing happnin here..."} issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) issue = jp.getIssue(issue_key) issue.Summary = "Indiana Jones and his hat" issue.Description = "wool fedora" issue.Priority = "Highest" issue.Assignee = JIRA_DEV_USER assert jp.updateIssue(issue) == True issueAgain = jp.getIssue(issue_key) assert issueAgain.Summary == "Indiana Jones and his hat" assert issueAgain.Description == "wool fedora" assert issueAgain.Priority == "Highest" assert issueAgain.Assignee == JIRA_DEV_USER assert jp.deleteIssue(issue_key)
def main(args): jira = JiraProxy(REG_USER_CONFIG) ## Create Issue issue_attributes = { "Summary": "Create Example", "Description": "A Bug at Creation.", "Priority": "High", "Fix Version/s": "cherry" } print( f'{"Key":<10} : {"Description":<20} : {"Created":<23} : {"Updated":<23}' ) print("-" * 90) issue_key = jira.createIssue(PROJECT_KEY, "Bug", issue_attributes) # returns an issue key issue = jira.getIssue(issue_key) desc, created, updated = [ issue[attr_name] for attr_name in ["Description", "Created", "Updated"] ] print( f'{issue_key:<10} : {desc:<20} : {created:<23.23} : {updated:<23.23}') time.sleep(1) issue["Description"] = "A Bug at Update 1" jira.updateIssue(issue) issue = jira.getIssue(issue_key) desc, created, updated = [ issue[attr_name] for attr_name in ["Description", "Created", "Updated"] ] print( f'{issue_key:<10} : {desc:<20} : {created:<23.23} : {updated:<23.23}')
def test_transition_newly_created_issue_to_in_progress_state(): """ transition a newly created issue to the In Progress state """ jp = JiraProxy(GOOD_VANILLA_SERVER_DEV_USER_CONFIG) work_item = {"Summary" : "Roller Coaster assembly point"} issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) # If the PROJECT_KEY_4 is used the following line would work #assert "Start Progress" in transitions.keys() jp.transitionIssueState(issue_key, "In Progress") issue = jp.getIssue(issue_key) assert issue.Status == "In Progress" assert jp.deleteIssue(issue_key)
def test_create_story_setting_one_value_for_label(): """ create a JIRA New Story issue that sets one label standard field """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = {"Summary": 'Labels of one state', "Labels": 'Confusion'} issue_key = jp.createIssue(PROJECT_KEY_1, "Story", work_item) issue_key_patt = re.compile(f'^{PROJECT_KEY_1}-\\d+') assert issue_key_patt.match(issue_key) story_issue = jp.getIssue(issue_key) assert story_issue['Labels'] == "Confusion" assert jp.deleteIssue(issue_key)
def test_update_of_summary_field(): """ create a minimal JIRA issue and update the Summary field """ ZLOG = "zooki.log" logger = BasicLogger(ZLOG) logger.level = 'DEBUG' conf = copy.copy(GOOD_VANILLA_SERVER_CONFIG) conf['logger'] = logger jp = JiraProxy(conf) work_item = {"Summary": "bowling alley decor"} issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) issue = jp.getIssue(issue_key) issue.Summary = "Mr. Bojangles will dance now." assert issue.Summary == "Mr. Bojangles will dance now." assert jp.updateIssue(issue) == True issueAgain = jp.getIssue(issue_key) assert issueAgain.Summary == "Mr. Bojangles will dance now." assert jp.deleteIssue(issue_key) os.remove(ZLOG)
def disable_test_resolution_attribute_uses_display_name_when_configured_to_use_custom_restrictive_workflow(): """ Resolution attribute uses Display Name when Jira is configured to use a custom workflow that is more restrictive than the simplified default workflow """ jp = JiraProxy(GOOD_VANILLA_SERVER_DEV_USER_CONFIG) work_item = {"Summary" : "Roller Coaster scream tester"} issue_key = jp.createIssue(PROJECT_KEY_4, "Bug", work_item) jp.transitionIssueState(issue_key, "Resolved", "Won't Do" ) issue = jp.getIssue(issue_key) assert issue.Status == "Resolved" assert issue.Resolution == "Won't Do" assert jp.deleteIssue(issue_key)
def test_create_story_with_single_custom_multiselect_field(): """ create a JIRA New Story issue that sets a multiselect custom field """ #jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) jp = JiraProxy(GOOD_VANILLA_ONDEMAND_CONFIG) work_item = {"Summary": 'Veg Stand', "Advent Category": 'green beans'} issue_key = jp.createIssue(OD_PROJECT_KEY_1, "Story", work_item) issue_key_patt = re.compile(f'^{OD_PROJECT_KEY_1}-\\d+') assert issue_key_patt.match(issue_key) story_issue = jp.getIssue(issue_key) assert story_issue['Advent Category'] == ['green beans'] assert jp.deleteIssue(issue_key)