def test_transaction_post_ok():
    assert TransactionPost(
        reference='reference',
        account='account',
        date='2020-02-02',
        type='inflow',
        amount=1.00,
        category='category',
    ) is not None
def test_transaction_post_type_wrong(type):
    with pytest.raises(ValidationError):
        TransactionPost(
            reference='reference',
            account='account',
            date='2020-02-02',
            type=type,
            amount=1.00,
            category='category',
        )
def test_transaction_post_amount_wrong(amount):
    with pytest.raises(ValidationError):
        TransactionPost(
            reference='reference',
            account='account',
            date='2020-02-02',
            type='inflow',
            amount=amount,
            category='category',
        )
def test_transaction_post_date_wrong(date):
    with pytest.raises(ValidationError):
        TransactionPost(
            reference='reference',
            account='account',
            date=date,
            type='inflow',
            amount=1.00,
            category='category',
        )
def test_transaction_post_category_wrong(category):
    with pytest.raises(ValidationError):
        TransactionPost(
            reference='reference',
            account='account',
            date='2020-02-02',
            type='inflow',
            amount=1.00,
            category=category,
        )
Exemple #6
0
def new_transaction(session, new_user, data_transaction):
    data = TransactionPost(
        reference=data_transaction['reference'],
        account=data_transaction['account'],
        date=data_transaction['date'],
        amount=data_transaction['amount'],
        type=data_transaction['type'],
        category=data_transaction['category'],
    )
    return Transaction.create(
        db_session=session,
        user_id=new_user.id,
        data=data,
    )
def test_transaction_create_ok(session, data_transaction):
    count1 = session.query(Transaction).count()
    users = User.get_users(db_session=session)
    data = TransactionPost(
        reference=data_transaction['reference'],
        account=data_transaction['account'],
        date=data_transaction['date'],
        amount=data_transaction['amount'],
        type=data_transaction['type'],
        category=data_transaction['category'],
    )
    Transaction.create(db_session=session, user_id=users[0].id, data=data)
    count2 = session.query(Transaction).count()
    assert count1 + 1 == count2