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_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_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_sad_refuse_update_an_invalid_field_name(): """ create a JIRA issue and refuse to update when field name is invalid """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = {"Summary": "This does not qualify to become a Bug"} issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) issue = jp.getIssue(issue_key) issue.Summary = "humma humma hummahhhh..." issue.Smurfette = "very blue" issue.Hyena = "spotted" with py.test.raises(JiraIssueError) as excinfo: jp.updateIssue(issue) actualErrorMessage = str(excinfo) assert r'Unrecognized field |Smurfette|' in actualErrorMessage assert jp.deleteIssue(issue_key)
def main(args): jira = JiraProxy(REG_USER_CONFIG) ## Create Epic issue_attributes = { #"Epic Name" : "Formentus Juva", #"Summary" : "In the infinite energetic unspeck of the pre-cataclysm", "Epic Name": "Dykolvut Tiskolid", "Summary": "Too many Beeelllliions in the digipay system", "Description": "Immense and unimaginable angst was burst forth upon the proto-void", } issue_key = jira.createIssue(PROJECT_KEY, "Epic", issue_attributes) # returns an issue key ## Read the Epic issue = jira.getIssue(issue_key) status = issue.Status print(f"Issue : {issue.key}") print(issue.brief()) print("") print("-" * 60) print(f'{"Key":<22} : {"Value"}') print("--------------- ----------") values = issue.attributeValues() for attribute_name, value in values: print(f'{attribute_name:<20} : {value}') print("") ## Update the Epic issue.Description = 'Unhound the barkulop hinderys' issue.Status = 'Done' issue.Assignee = 'devuser' jira.updateIssue(issue) upd_issue = jira.transitionIssueState(issue.key, 'Done') print(issue.brief()) ## Delete the Epic jira.deleteIssue(upd_issue.key) print(f'{issue.key} was deleted')
def test_sad_refuse_update_with_invalid_priority_value(): """ refuse to update a JIRA issue when provided with an invalid priority value """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = { "Summary": "fortrado municipal detention center for pronghorns", "Reporter": "testuser", "Assignee": JIRA_DEV_USER, "Priority": "Highest", } issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) issue = jp.getIssue(issue_key) issue.Priority = "Waffelicious" with py.test.raises(JiraIssueError) as excinfo: jp.updateIssue(issue) actualErrorMessage = str(excinfo) assert '"Waffelicious" not an allowed value for the Priority field' in actualErrorMessage 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 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_sad_fail_update_when_resolution_is_invalid_value(): """ will fail to update the issue when Resolution is set to an invalid value (for jira's configuration of allowed Resolution values), but JIRA is configured to allow setting a Resolution """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = {"Summary": "Rally Cloudy Day"} issue_key = jp.createIssue(PROJECT_KEY_2, "Bug", work_item) issue = jp.getIssue(issue_key) assert issue.Resolution is None issue.Summary = "Rally Foggy Day" issue.Resolution = "No Sun" with py.test.raises(JiraIssueError) as excinfo: jp.updateIssue(issue) actualErrorMessage = str(excinfo) assert f'"No Sun" not an allowed value' in actualErrorMessage assert jp.deleteIssue(issue_key)
def test_sad_refuse_update_resolution_with_invalid_value(): """ create a minimal JIRA issue and refuse to update the Resolution field when field value is invalid """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = {"Summary": "Rally Cloudy Day"} issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) issue = jp.getIssue(issue_key) bad_value = "Foobar" assert issue.Resolution is None issue.Summary = "Rally Foggy Day" issue.Resolution = bad_value with py.test.raises(JiraIssueError) as excinfo: jp.updateIssue(issue) actual_error_message = str(excinfo) expected_error_message = '"Foobar" not an allowed value for the Resolution field' assert expected_error_message in actual_error_message assert jp.deleteIssue(issue_key)
def test_sad_refuse_update_with_invalid_reporter_value(): """ refuse to update a JIRA issue when provided with an invalid reporter value """ jp = JiraProxy(GOOD_VANILLA_SERVER_CONFIG) work_item = { "Summary": "fundamental physical properties preclude the formation is this solid", "Reporter": "testuser", "Assignee": JIRA_DEV_USER, "Priority": "Highest", } issue_key = jp.createIssue(PROJECT_KEY_1, "Bug", work_item) issue = jp.getIssue(issue_key) issue.Reporter = "pelicanbeak" with py.test.raises(JiraProxyError) as excinfo: jp.updateIssue(issue) actualErrorMessage = str(excinfo) reporter_bad_pattern = re.compile( r'JIRA update errors .*The reporter specified is not a user') assert reporter_bad_pattern.search(actualErrorMessage) is not None assert jp.deleteIssue(issue_key)
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 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_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_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_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_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 test_sad_refuse_update_when_provided_with_bad_issue_type(): """ refuse to update a JIRA issue when provided with a bad 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 = "this should never leave the factory" issue["Issue Type"] = "Bugle" with py.test.raises(JiraProxyError) as excinfo: issue_key = jp.updateIssue(issue) actualErrorMessage = str(excinfo) assert 'Could not find issuetype by id or name' in actualErrorMessage 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)