from karma import User, Transaction alice = User('alice') bob = User('bob') tim = User('tim') transactions = [ Transaction(giver=alice, points=1), Transaction(giver=bob, points=2), Transaction(giver=tim, points=3), Transaction(giver=tim, points=4), ] def test_init(): assert alice.name == 'alice' assert bob.name == 'bob' assert alice._transactions == [] assert bob._transactions == [] def test_adding_karma(): bob + transactions[0] assert bob.karma == 1 alice + transactions[1] assert alice.karma == 2 bob + transactions[2] assert bob.karma == 4 alice + transactions[3] assert alice.karma == 6
def alice(): return User('alice')
def bob(): return User('bob')
def tim(): return User('tim')