def test_second_rule(
        base_endpoint,
        core_manager,
        managed_application_client,
        server_rule_prototype,
        server_response_prototype,
    ):
    """Check that rule can be triggered if no match has been found by other rules.

    1. Create a rule, that does not find match for any request.
    2. Create a rule, that is triggered for every request.
    3. Create different responses for the rules.
    4. Make a request.
    5. Check that response for the second rule is returned.
    """
    implementation_triggered = False
    def _no_match_implementation(*args, **kwargs):
        # pylint: disable=unused-argument
        nonlocal implementation_triggered
        implementation_triggered = True
        return False

    no_match_rule = server_rule_prototype.create_new(match_implementation=_no_match_implementation)
    no_match_rule_id = core_manager.add_rule(rule=no_match_rule)

    match_rule = server_rule_prototype.create_new(match_implementation=True)
    match_rule_id = core_manager.add_rule(rule=match_rule)

    no_match_response = server_response_prototype.create_new(
        builder_implementation=b"No match response",
        )
    core_manager.set_response(rule_id=no_match_rule_id, response=no_match_response)

    match_response = server_response_prototype.create_new(
        builder_implementation=b"Match response",
        )
    core_manager.set_response(rule_id=match_rule_id, response=match_response)

    http_response = managed_application_client.get(base_endpoint)
    assert implementation_triggered, "First rule was not checked"
    assert http_response.status_code == 200, "Wrong status code"
    assert http_response.data == b"Match response", "Wrong body"