def test_get_dependencies_1_external(issue_mock): mock_issuelinks = PropertyMock( return_value=[ fakes.IssueLink("inwardIssue", f"{issue_mock.fields.project.key}-1"), fakes.IssueLink("outwardIssue", f"EXT-111"), ] ) type(issue_mock.fields).issuelinks = mock_issuelinks links = issuelinks.get_external_dependencies(issue_mock) assert ["EXT-111"] == [i.key for i in links]
def issue_mock(): m = mock.MagicMock() type(m.fields.project).key = mock.PropertyMock(return_value="COE") type(m.fields).issuelinks = mock.PropertyMock(return_value=[ fakes.IssueLink("inwardIssue", f"{m.fields.project.key}-1"), fakes.IssueLink("inwardIssue", f"{m.fields.project.key}-2"), fakes.IssueLink("inwardIssue", "EXT-1", "Blocks"), fakes.IssueLink("outwardIssue", "EXT-2"), ]) type(m.fields).created = mock.PropertyMock(return_value='2020-03-03T15:02:23.310+0000') type(m.fields).resolutiondate = mock.PropertyMock(return_value='2020-03-04T15:02:23.310+0000') return m
def issue_mock(): m = MagicMock() type(m.fields.project).key = PropertyMock(return_value="COE") type(m.fields).issuelinks = PropertyMock( return_value=[ fakes.IssueLink("inwardIssue", f"{m.fields.project.key}-1"), fakes.IssueLink("inwardIssue", f"{m.fields.project.key}-2"), fakes.IssueLink("inwardIssue", "EXT-1", "Blocks"), fakes.IssueLink("outwardIssue", "EXT-2"), ] ) return m
def test_external_links_20(jira_mock): i5 = fakes.Issue('ISSUE-5') i5.fields.issuelinks = [ fakes.IssueLink('inwardIssue', 'Dep-1'), fakes.IssueLink('inwardIssue', 'Dep-2'), fakes.IssueLink('outwardIssue', 'Dep-3') ] jira_mock.search_issues.return_value += [i5] p, all_issues, all_with_dep = dep.dependency_factor(jira_mock, "jql") assert p == 20 assert len(all_with_dep) == 1 assert all_with_dep[0].key == 'ISSUE-5' assert len(all_issues) == 5
def test_count_by_link_type(): i1 = fakes.Issue('ISSUE-1', epic_name='my epic') i1.fields.issuelinks = [ fakes.IssueLink('outwardIssue', 'DEP-1'), fakes.IssueLink('inwardIssue', 'DEP-2') ] issue_cache_1 = fakes.IssueCache(i1) issue_cache_1.linked_issues = { "ISSUE-10": fakes.Issue('ISSUE-10', epic_name='linked epic') } issue_cache_2 = mock.MagicMock() issue_cache_2.linked_issues = {"ISSUE-20": fakes.Issue('ISSUE-20')} linked_issues = dep.count_by_link_type([issue_cache_1, issue_cache_2]) assert linked_issues == {'Dependency': 2}
def test_get_external_blocked_by(issue_mock): links = issuelinks.get_external_blocked_by(issue_mock) assert links == [] mock_issuelinks = PropertyMock() mock_issuelinks.return_value = [fakes.IssueLink("outwardIssue", "EXT-2", "Blocks")] type(issue_mock.fields).issuelinks = mock_issuelinks links = issuelinks.get_external_blocked_by(issue_mock) assert links == ["EXT-2"]
def test_external_links_0( jira_mock): # issue-5 is a dependency for the other issue i5 = fakes.Issue('ISSUE-5') i5.fields.issuelinks = [ fakes.IssueLink('inwardIssue', 'Dep-1'), ] jira_mock.search_issues.return_value = [i5] p, all_issues, all_with_dep = dep.dependency_factor(jira_mock, "jql") assert p == 0 assert len(all_with_dep) == 0 assert len(all_issues) == 1
def test_get_link_key(): link_key = '101' link = fakes.IssueLink('inwardIssue', link_key) lk = dep.get_link_key(link) assert link_key == lk