import pytest

from main import app
from main import parse_args as parse_main_args
from dev import parse_args as parse_dev_args


def test_main_parse_args_should_default_to_subset():
    args = parse_main_args([])
    assert args.rule_hit_mode == "subset"


def test_main_parse_args_should_accept_all_mode():
    args = parse_main_args(["--rule-hit-mode", "all"])
    assert args.rule_hit_mode == "all"


def test_dev_parse_args_should_reject_invalid_mode():
    with pytest.raises(SystemExit):
        parse_dev_args(["--rule-hit-mode", "invalid"])


def test_app_should_register_credit_mock_routes():
    paths = {route.path for route in app.routes}

    assert "/api/service/interface/invokeService/xfeature" in paths
    assert "/api/service/interface/invokeService/xfeatureResult" in paths
    assert "/credit/health" in paths
