Exemplo n.º 1
0
def test_update_model():
    email_address = '*****@*****.**'
    password = bytes('zzz', 'ascii')
    verified = True
    role = 'employee'

    try:
        db_session = Session()

        # create dummy account
        account = Account(
            email_address=email_address,
            password=password,
            verified=False,  # to update 1
            role='student'  # to update 2
            )
        db_session.add(account)
        db_session.commit()

        # update account
        update_model(
            Account,
            Account.email_address.name,
            email_address,
            **{
                Account.verified.name: verified,
                Account.role.name: role
                }
            )

        # query updated dummy account
        account = db_session.query(
            Account
            ).filter_by(email_address=email_address).first()

        # test
        eq_(email_address, account.email_address)
        eq_(password, account.password)
        eq_(verified, account.verified)
        eq_(role, account.role)

    finally:
        # delete dummy account
        db_session.delete(account)
        db_session.commit()
Exemplo n.º 2
0
def test_update_model():
    email_address = '*****@*****.**'
    password = bytes('zzz', 'ascii')
    verified = True
    role = 'employee'

    try:
        db_session = Session()

        # create dummy account
        account = Account(
            email_address=email_address,
            password=password,
            verified=False,  # to update 1
            role='student'  # to update 2
        )
        db_session.add(account)
        db_session.commit()

        # update account
        update_model(
            Account, Account.email_address.name, email_address, **{
                Account.verified.name: verified,
                Account.role.name: role
            })

        # query updated dummy account
        account = db_session.query(Account).filter_by(
            email_address=email_address).first()

        # test
        eq_(email_address, account.email_address)
        eq_(password, account.password)
        eq_(verified, account.verified)
        eq_(role, account.role)

    finally:
        # delete dummy account
        db_session.delete(account)
        db_session.commit()
Exemplo n.º 3
0
def delete_dummy_student():
    student = db_session.query(Student).filter_by(ocmr='0000').first()
    db_session.delete(student)
    db_session.commit()
Exemplo n.º 4
0
def delete_dummy_student():
    student = db_session.query(Student).filter_by(ocmr='0000').first()
    db_session.delete(student)
    db_session.commit()