コード例 #1
0
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()
コード例 #2
0
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()
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
0
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 == []
コード例 #6
0
ファイル: conftest.py プロジェクト: tlwr/notifications-api
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
コード例 #7
0
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
コード例 #8
0
ファイル: conftest.py プロジェクト: cds-snc/notification-api
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
コード例 #9
0
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 == []
コード例 #10
0
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 == []
コード例 #11
0
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