示例#1
0
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
示例#2
0
def alice():
    return User('alice')
示例#3
0
def bob():
    return User('bob')
示例#4
0
def tim():
    return User('tim')