def make_invitation(user, service, age=None, email_address="*****@*****.**"): verify_code = InvitedUser(email_address=email_address, from_user=user, service=service, status='pending', created_at=datetime.utcnow() - (age or timedelta(hours=0)), permissions='manage_settings', folder_permissions=[str(uuid.uuid4())]) db.session.add(verify_code) db.session.commit()
def make_invitation(user, service, age=timedelta(hours=0), email_address="*****@*****.**"): verify_code = InvitedUser(email_address=email_address, from_user=user, service=service, status='pending', created_at=datetime.utcnow() - age, permissions='manage_settings') db.session.add(verify_code) db.session.commit()
def test_create_invited_user(notify_db, notify_db_session, sample_service): assert InvitedUser.query.count() == 0 email_address = '*****@*****.**' invite_from = sample_service.users[0] data = { 'service': sample_service, 'email_address': email_address, 'from_user': invite_from, 'permissions': 'send_messages,manage_service' } invited_user = InvitedUser(**data) save_invited_user(invited_user) assert InvitedUser.query.count() == 1 assert invited_user.email_address == email_address assert invited_user.from_user == invite_from permissions = invited_user.get_permissions() assert len(permissions) == 2 assert 'send_messages' in permissions assert 'manage_service' in permissions
def test_create_invited_user(notify_db, notify_db_session, sample_service): assert InvitedUser.query.count() == 0 email_address = "*****@*****.**" invite_from = sample_service.users[0] data = { "service": sample_service, "email_address": email_address, "from_user": invite_from, "permissions": "send_messages,manage_service", "folder_permissions": [], } invited_user = InvitedUser(**data) save_invited_user(invited_user) assert InvitedUser.query.count() == 1 assert invited_user.email_address == email_address assert invited_user.from_user == invite_from permissions = invited_user.get_permissions() assert len(permissions) == 2 assert "send_messages" in permissions assert "manage_service" in permissions assert invited_user.folder_permissions == []
def sample_invited_user(notify_db_session): service = create_service(check_if_service_exists=True) to_email_address = '*****@*****.**' from_user = service.users[0] data = { 'service': service, 'email_address': to_email_address, 'from_user': from_user, 'permissions': 'send_messages,manage_service,manage_api_keys', 'folder_permissions': ['folder_1_id', 'folder_2_id'], } invited_user = InvitedUser(**data) save_invited_user(invited_user) return invited_user
def create_invited_user(service=None, to_email_address=None): if service is None: service = create_service() if to_email_address is None: to_email_address = '*****@*****.**' from_user = service.users[0] data = { 'service': service, 'email_address': to_email_address, 'from_user': from_user, 'permissions': 'send_messages,manage_service,manage_api_keys' } invited_user = InvitedUser(**data) save_invited_user(invited_user) return invited_user
def sample_invited_user(notify_db, notify_db_session, service=None, to_email_address=None): if service is None: service = create_service(check_if_service_exists=True) if to_email_address is None: to_email_address = "*****@*****.**" from_user = service.users[0] data = { "service": service, "email_address": to_email_address, "from_user": from_user, "permissions": "send_messages,manage_service,manage_api_keys", "folder_permissions": ["folder_1_id", "folder_2_id"], } invited_user = InvitedUser(**data) save_invited_user(invited_user) return invited_user
def test_create_invited_user_sets_default_folder_permissions_of_empty_list( notify_db, notify_db_session, sample_service, ): assert InvitedUser.query.count() == 0 invite_from = sample_service.users[0] data = { 'service': sample_service, 'email_address': '*****@*****.**', 'from_user': invite_from, 'permissions': 'send_messages,manage_service', } invited_user = InvitedUser(**data) save_invited_user(invited_user) assert InvitedUser.query.count() == 1 assert invited_user.folder_permissions == []
def test_create_invited_user_sets_default_folder_permissions_of_empty_list( notify_db, notify_db_session, sample_service, ): assert InvitedUser.query.count() == 0 invite_from = sample_service.users[0] data = { "service": sample_service, "email_address": "*****@*****.**", "from_user": invite_from, "permissions": "send_messages,manage_service", } invited_user = InvitedUser(**data) save_invited_user(invited_user) assert InvitedUser.query.count() == 1 assert invited_user.folder_permissions == []
def create_invited_user(service=None, to_email_address=None): if service is None: service = create_service() if to_email_address is None: to_email_address = "*****@*****.**" from_user = service.users[0] data = { "service": service, "email_address": to_email_address, "from_user": from_user, "permissions": "send_messages,manage_service,manage_api_keys", "folder_permissions": [str(uuid.uuid4()), str(uuid.uuid4())], } invited_user = InvitedUser(**data) save_invited_user(invited_user) return invited_user