async def _get_branch_protection_conditions( ctxt: context.Context, ) -> typing.List[filter.Filter]: return [ rules.RuleCondition(f"check-success={check}") for check in await ctxt.repository.get_branch_protection_checks( ctxt.pull["base"]["ref"]) ]
async def _get_branch_protection_conditions( ctxt: context.Context, ) -> typing.List[filter.Filter]: branch = await ctxt.repository.get_branch(ctxt.pull["base"]["ref"]) if not branch["protection"]["enabled"]: return [] return [ rules.RuleCondition(f"check-success={check}") for check in branch["protection"]["required_status_checks"]["contexts"] ]
def test_invalid_condition_re(): with pytest.raises(voluptuous.Invalid): rules.RuleCondition("head~=(bar")
def test_valid_condition(): c = rules.RuleCondition("head~=bar") assert str(c) == "head~=bar"