import pytest from campaigns.meta.constants import SCOPE_PAGES_SHOW_LIST, SCOPE_PUBLIC_PROFILE from campaigns.meta.dtos import FacebookUser @pytest.mark.parametrize( "granted_scopes, scopes, expected", [ ([], [], True), (["scope1", "scope2"], [], True), (["scope1", "scope2"], ["scope1", "scope2"], True), (["scope1", "scope2", "scope3"], ["scope1", "scope2"], True), (["scope1", "scope2"], ["scope1", "scope2", "scope3"], False), ([], ["scope1", "scope2", "scope3"], False), ], ) def test_facebook_user_scopes_sufficient( granted_scopes: list[str], scopes: list[str], expected: bool ) -> None: user = FacebookUser( id="123", name="Test User", picture="https://", granted_scopes=granted_scopes, ) assert user.scopes_sufficient(scopes=scopes) == expected @pytest.mark.parametrize( "granted_scopes, expected", [ ([SCOPE_PUBLIC_PROFILE, SCOPE_PAGES_SHOW_LIST], True), ([SCOPE_PUBLIC_PROFILE], False), ([], False), ], ) def test_facebook_user_has_pages(granted_scopes: list[str], expected: bool) -> None: user = FacebookUser( id="123", name="Test User", picture="https://", granted_scopes=granted_scopes, ) assert user.has_pages_scope() == expected