def add_users(): users = [ User(username='******', slack='rando', email='*****@*****.**', name_first='Matt', name_last='Arcidy'), User(username='******', slack='ruthgrace', email='*****@*****.**', name_first='Ruth Grace', name_last='Wong'), User(username='******', slack='jams', email='*****@*****.**', name_first='Jeremey', name_last='Lleywen'), User(username='******', slack='sigint', email='*****@*****.**', name_first='Nick', name_last='Whatever') ] [db.session.add(user) for user in users] db.session.commit()
def test_bad_formed_user(): with pytest.raises(ValidateError): u = User(username=123, email="*****@*****.**") with pytest.raises(ValidateError): u = User(username=None, email="*****@*****.**") with pytest.raises(ValidateError): u = User(username="******", email=None)
def model_objects(): objects = { 'u1': User(id=1, username="******", email="*****@*****.**"), 'u2': User(id=2, username="******", email="*****@*****.**"), 'u3': User(id=3, username="******", email="*****@*****.**"), 'u4': User(id=4, username="******", email="*****@*****.**"), 'usd': Currency(id=1, code="USD", name="US Dollar"), 'btc': Currency(id=2, code="BTC", name="Bitcoin"), 'acct1': Account(id=1, ccy_id=1, name="USD Credits"), 'acct2': Account(id=2, ccy_id=1, name="USD Debits"), 'acct3': Account(id=3, ccy_id=2, name="BTC Wallet"), } return objects
def test_new_user(): uname = "rando" em = "*****@*****.**" user = User(username=uname, email=em) assert user.username == uname assert user.email == em
def test_insert_user(): uname = 'rando' em = '*****@*****.**' user = User(username=uname, email=em) db.session.add(user) db.session.commit() retrieved_user = db.session.query(User).one() assert user.username == retrieved_user.username assert user.email == retrieved_user.email