Beispiel #1
0
def test_queue_summary_subscription(active, summary):
    ctxt = mock.Mock(subscription=subscription.Subscription(
        123,
        active,
        "We're just testing",
        {},
        frozenset({subscription.Features.PRIORITY_QUEUES}),
    ))
    ctxt.missing_feature_reason = subscription.Subscription.missing_feature_reason
    ctxt.pull = {
        "base": {
            "repo": {
                "owner": {
                    "login": "******",
                },
            },
        },
    }
    q = mock.Mock(installation_id=12345)
    q.get_pulls.return_value = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    q.get_config.side_effect = gen_config(
        [4000, 3000, 3000, 3000, 2000, 2000, 1000, 1000, 1000])
    with mock.patch.object(merge.queue.Queue, "from_context", return_value=q):
        action = merge.MergeAction(
            voluptuous.Schema(merge.MergeAction.validator)({}))
        assert summary == action.get_queue_summary(ctxt, q)
Beispiel #2
0
async def test_queue_summary(redis_cache):
    repository = mock.Mock(
        get_pull_request_context=mock.AsyncMock(
            return_value=mock.Mock(pull={"title": "foo"})
        )
    )
    ctxt = mock.Mock(
        repository=repository,
        subscription=subscription.Subscription(
            redis_cache,
            123,
            True,
            "We're just testing",
            frozenset({subscription.Features.PRIORITY_QUEUES}),
        ),
    )
    ctxt.missing_feature_reason = subscription.Subscription.missing_feature_reason
    ctxt.pull = {
        "base": {
            "repo": {
                "owner": {
                    "login": "******",
                },
            },
        },
    }
    q = mock.AsyncMock(installation_id=12345)
    q.get_pulls.return_value = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    q.get_config.side_effect = gen_config(
        [4000, 3000, 3000, 3000, 2000, 2000, 1000, 1000, 1000]
    )
    with mock.patch.object(merge.naive.Queue, "from_context", return_value=q):
        action = merge.MergeAction(voluptuous.Schema(merge.MergeAction.validator)({}))
        assert """**Required conditions for merge:**


**The following pull requests are queued:**
| | Pull request | Priority |
| ---: | :--- | :--- |
| 1 | foo #1 | 4000 |
| 2 | foo #2 | high |
| 3 | foo #3 | high |
| 4 | foo #4 | high |
| 5 | foo #5 | medium |
| 6 | foo #6 | medium |
| 7 | foo #7 | low |
| 8 | foo #8 | low |
| 9 | foo #9 | low |

---

""" + constants.MERGIFY_PULL_REQUEST_DOC == await action._get_queue_summary(
            ctxt, mock.Mock(missing_conditions=[], conditions=[]), q
        )