示例#1
0
def test_claim_assigned():
    """Test trying to claim something that's already assigned. (Assume user error)."""
    hook = ClaimHook()
    payload = {
        "issue": {
            "assignee": {},
        },
        "comment": {
            "body": "So exciting. Claimed!"
        }
    }
    assert not hook.should_perform_action(payload), "Already assigned."
示例#2
0
def test_claim():
    """Test successful claim."""
    hook = ClaimHook()
    payload = {
        "issue": {
            "assignee": None,
        },
        "comment": {
            "body": "So exciting. Claimed!"
        }
    }
    assert hook.should_perform_action(payload), "Claimed."
示例#3
0
def test_no_claim_comment():
    """Test a comment with no special keywords."""
    hook = ClaimHook()
    payload = {
        "issue": {
            "assignee": None,
        },
        "comment": {
            "body": "Some comment here. Nothing special."
        }
    }
    assert not hook.should_perform_action(payload), "No-op"
示例#4
0
def test_claim_payload():
    """Test claiming using a JSON payload. Just a double-check."""
    hook = ClaimHook()
    payload = get_payload('issue_comment_unassigned.json')
    assert hook.should_perform_action(payload), "Unassigned + 'claimed'."

    actions = hook.actions(payload, Mock())
    assert actions[0]["args"] == {
        "issue_url": "https://api.github.com/repos/user-foo/repo-bar/issues/14",
        "assignee": "user-foo",
    }

    assert actions[1]["args"] == {
        "issue_url": "https://api.github.com/repos/user-foo/repo-bar/issues/14",
        "labels": []
    }