Esempio n. 1
0
def test_company_add_users(clean_db):
    company = Company()
    company.name = 'test name'

    user1 = User()
    user1.username = '******'
    user2 = User()
    user2.username = '******'

    db.session.add(user1)
    db.session.add(user2)
    db.session.add(company)

    company.add_user(user1)
    company.add_user(user2)

    users = company.users

    assert user1 in users
    assert user2 in users
Esempio n. 2
0
def test_users_company_name(clean_db):
    company = Company()
    company.name = 'test name'

    user1 = User()
    user1.username = '******'

    db.session.add(user1)
    db.session.add(company)

    company.add_user(user1)

    db.session.commit()

    assert user1.company.name == company.name
Esempio n. 3
0
def test_company_owner(clean_db):
    name = 'Test Company'
    company = Company()
    company.name = name

    user1 = User()
    user1.username = '******'

    db.session.add(user1)
    db.session.add(company)

    company.set_company_owner(user1)
    db.session.commit()

    db_company = Company.query.filter_by(name=name).first()

    assert user1 == db_company.owner