def test_append_no_one_assigned(): i = create_issue([], []) changes = i.append(['a', 'b']) assert changes == [ iss.IssueChange(iss.CHANGE_ADD, 'a'), iss.IssueChange(iss.CHANGE_ADD, 'b') ] assert i.assignees == ['a', 'b']
def test_clear_add_reapply_no_one_assigned(): i = create_issue([], []) i.append(['a']) # by rules should be assigned result = i.clear_add_reapply(['b']) assert result == [ iss.IssueChange(iss.CHANGE_REMAIN, 'a'), iss.IssueChange(iss.CHANGE_ADD, 'b') ] assert i.assignees == ['a', 'b']
def test_apply_label_add(): i = create_issue([], []) result = i.apply_label('test') assert result == [ iss.IssueChange(iss.CHANGE_FALLBACK, f'added label "test"') ] assert i.labels == ['test']
def test_issue_replace_already_assigned(): assignees = ['a'] i = create_issue([], assignees) result = i.replace(['b']) assert result == [iss.IssueChange(iss.CHANGE_REMAIN, 'a')] assert i.assignees == assignees
def test_apply_label_already_have(): i = create_issue(['test'], []) result = i.apply_label('test') assert result == [ iss.IssueChange(iss.CHANGE_FALLBACK, f'already has label "test"') ] assert i.labels == ['test']
def test_apply_label_add_second(): i = create_issue(['test'], []) result = i.apply_label('important') assert result == [ iss.IssueChange(iss.CHANGE_FALLBACK, f'added label "important"') ] assert i.labels == ['test', 'important']
def process(self, rules, fallback, dry_run: bool): for issue in self.issues: applies = [] for rule in rules: if rule.validate(issue): applies.append(rule.owner) changes = self._apply_strategy(issue, applies) c = self._check_fallback(issue, fallback) for i in c: changes.append(i) changes.sort(key=lambda x: x.name.lower()) if not dry_run and self._has_changes( changes) and not self._patch_issue(issue): changes = [ iss.IssueChange( iss.CHANGE_ERROR, f'Could not update issue {self.repo}#{issue.number}') ] self._print_result(issue.number, issue.url, changes)
def test_issue_replace_empty_input(): i = create_issue([], ['a']) result = i.replace([]) assert result == [iss.IssueChange(iss.CHANGE_REMAIN, 'a')] assert i.assignees == ['a']
def test_issue_replace_no_one(): i = create_issue([], []) result = i.replace(['a']) assert result == [iss.IssueChange(iss.CHANGE_ADD, 'a')] assert i.assignees == ['a']
def test_append_empty_input(): i = create_issue([], ['a']) changes = i.append([]) assert changes == [iss.IssueChange(iss.CHANGE_REMAIN, 'a')] assert i.assignees == ['a']