import pytest from jwtauth.utils import is_path_match_re from email_campaigns.config import settings @pytest.fixture(scope="module") def exclude_paths() -> list[str]: return settings.jwt_auth_exclude_paths @pytest.mark.parametrize( "path", [ "/source-campaigns/smf/campaign-123/automated-emails", "/source-campaigns/wyng/some-uuid-here/automated-emails", "/source-campaigns/tunespeak/12345/automated-emails", "/source-campaigns/smf/550e8400-e29b-41d4-a716-446655440000/automated-emails", ], ) def test_source_campaigns_automated_emails_excluded( exclude_paths: list[str], path: str, ) -> None: assert is_path_match_re(path, match=exclude_paths) is True @pytest.mark.parametrize( "path", [ "/source-campaigns/list", "/source-campaigns/smf/automated-emails", "/source-campaigns/automated-emails", ], ) def test_other_source_campaign_paths_not_excluded( exclude_paths: list[str], path: str, ) -> None: assert is_path_match_re(path, match=exclude_paths) is False