示例#1
0
def test_bulk_update(app):
    with app.app_context():
        frequency = Frequency.objects(label='monthly').first()
        series = insert_series(
            USERNAME1,
            SERIES_NAME,
            PAYER1,
            PAYEE1,
            AMOUNT,
            START_DATE1_DATE,
            END_DATE1_DATE,
            frequency)
        assert 25 == get_transactions_for_username(USERNAME1).count()
        assert series is not None
        assert 25 == len(series.transactions)
        assert get_series_by_id(series.id) is not None
        assert 25 == len(get_series_by_id(series.id).transactions)
        assert 1 == len(get_series_by_username(USERNAME1))
        assert 1 == len(get_series(USERNAME1, {}))
        assert 1 == len(get_series(USERNAME1, {'payer': PAYER1}))

        from_data = {'username': USERNAME1, 'payer': PAYER1}
        to_data = {'username': USERNAME1, 'payer': PAYER2}

        bulk_update(from_data, to_data)
        assert 25 == get_transactions_for_username(USERNAME1).count()
        assert series is not None
        assert 25 == len(series.transactions)
        assert get_series_by_id(series.id) is not None
        assert 25 == len(get_series_by_id(series.id).transactions)
        assert 1 == len(get_series_by_username(USERNAME1))
        assert 1 == len(get_series(USERNAME1, {}))
        assert 1 == len(get_series(USERNAME1, {'payer': PAYER2}))
        for transaction in get_series_by_id(series.id).transactions:
            assert PAYER2 == transaction.payer.account_name
示例#2
0
def test_delete_series(app):
    with app.app_context():
        frequency = Frequency.objects(label='monthly').first()
        series = insert_series(
            USERNAME1,
            SERIES_NAME,
            PAYER1,
            PAYEE1,
            AMOUNT,
            START_DATE1_DATE,
            END_DATE1_DATE,
            frequency)
        assert 25 == get_transactions_for_username(USERNAME1).count()
        assert series is not None
        transactions = series.transactions
        assert 25 == len(transactions)
        assert get_series_by_id(series.id) is not None
        assert 25 == len(get_series_by_id(series.id).transactions)
        assert 1 == len(get_series_by_username(USERNAME1))
        assert 1 == len(get_series(USERNAME1, {}))
        assert 1 == len(get_series(USERNAME1, {'payer': PAYER1}))
        delete_series(series.id)
        assert get_series_by_id(series.id) is None
        assert 0 == len(get_series_by_username(USERNAME1))
        assert get_transaction(transactions[0].id) is None
        assert 0 == len(get_series(USERNAME1, {}))
        assert 0 == len(get_series(USERNAME1, {'payer': PAYER1}))
示例#3
0
def test_get_transactions_for_username(app, test_user):
    with app.app_context():

        t1s = create_transactions(count=3)
        t2s = create_transactions(username=USERNAME2, count=4)

        for transaction in t1s:
            insert_transaction(transaction)

        for transaction in t2s:
            insert_transaction(transaction)

        ts1 = get_transactions_for_username(USERNAME1)
        ts2 = get_transactions_for_username(USERNAME2)

        assert ts1.count() == 3
        assert ts2.count() == 4
示例#4
0
def all_transactions():
    transactions = list(get_transactions_for_username(g.username))
    return render_template('transactions/all.html', transactions=transactions)
示例#5
0
def test_create_transactions_annually(app):
    with app.app_context():
        frequency = Frequency.objects(label='annually').first()
        create_transactions(USERNAME1, PAYER1, PAYEE1, AMOUNT, START_DATE1_DATE, END_DATE1_DATE, frequency)
        assert 3 == get_transactions_for_username(USERNAME1).count()
示例#6
0
def test_create_transactions_monthly_after(app):
    with app.app_context():
        end_date = datetime.strptime('1984-05-15', '%Y-%m-%d')
        frequency = Frequency.objects(label='monthly').first()
        create_transactions(USERNAME1, PAYER1, PAYEE1, AMOUNT, START_DATE1_DATE, end_date, frequency)
        assert 25 == get_transactions_for_username(USERNAME1).count()