Esempio n. 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
Esempio n. 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}))
Esempio n. 3
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()
Esempio n. 4
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()