def test_registered_user_knows_its_permissions(): registered = make_registered_user( permissions=[Permission.lookup_isni.value]) assert_that(registered.has_permission(Permission.lookup_isni), is_(True), "isni lookup?") assert_that(registered.has_permission(Permission.assign_isni), is_(False), "isni assign?")
def tests_overwrites_user_data_on_store(store): store.store_user(make_registered_user(email="*****@*****.**", api_key="token", permissions=["isni.lookup"])) store.store_user(make_anonymous_user()) overwritten_user = store.load_user() assert_that(overwritten_user, user_with(email=None, api_key=None, permissions=empty()), "overwritten user")
def tests_removes_user_credentials_from_settings_store_on_sign_out(store): store.should_receive("load_user").and_return(make_registered_user(email="*****@*****.**", api_key="token", permissions=("isni.lookup", "isni.assign"))) session = load_session_from(store) store.should_receive("remove_user").once() session.logout()
def tests_loads_user_information_from_settings_store_and_logs_user_in(store): store.should_receive("load_user").and_return(make_registered_user(email="*****@*****.**", api_key="token", permissions=("isni.lookup", "isni.assign"))) session = load_session_from(store) assert_that(session.current_user, has_properties(email="*****@*****.**", api_key="token", permissions=contains("isni.lookup", "isni.assign")))
def tests_overwrites_user_data_on_store(store): store.store_user( make_registered_user(email="*****@*****.**", api_key="token", permissions=["isni.lookup"])) store.store_user(make_anonymous_user()) overwritten_user = store.load_user() assert_that(overwritten_user, user_with(email=None, api_key=None, permissions=empty()), "overwritten user")
def tests_round_trips_user_to_settings_file(store): store.store_user( make_registered_user(email="*****@*****.**", api_key="token", permissions=["isni.lookup"])) persisted_user = store.load_user() assert_that( persisted_user, user_with(email="*****@*****.**", api_key="token", permissions=["isni.lookup"]))
def test_registered_user_knows_its_permissions(): registered = make_registered_user(permissions=[Permission.lookup_isni.value]) assert_that(registered.has_permission(Permission.lookup_isni), is_(True), "isni lookup?") assert_that(registered.has_permission(Permission.assign_isni), is_(False), "isni assign?")
def test_registered_user_knows_its_api_key(): registered = make_registered_user(api_key="0123456789") assert_that(registered.api_key, is_("0123456789"), "registered api key")
def test_registered_user_knows_its_email(): registered = make_registered_user(email="*****@*****.**") assert_that(registered.email, is_("*****@*****.**"), "registered email")
def test_registered_user_has_permission_to_lookup_isni(): registered = make_registered_user() assert_that(registered.has_permission(Permission.lookup_isni), is_(True), "grant to registered")
def tests_round_trips_user_to_settings_file(store): store.store_user(make_registered_user(email="*****@*****.**", api_key="token", permissions=["isni.lookup"])) persisted_user = store.load_user() assert_that(persisted_user, user_with(email="*****@*****.**", api_key="token", permissions=["isni.lookup"]))