diff --git a/biweeklybudget/tests/acceptance/flaskapp/views/test_accounts.py b/biweeklybudget/tests/acceptance/flaskapp/views/test_accounts.py index 4ab83f24..6bc51518 100644 --- a/biweeklybudget/tests/acceptance/flaskapp/views/test_accounts.py +++ b/biweeklybudget/tests/acceptance/flaskapp/views/test_accounts.py @@ -118,7 +118,7 @@ def test_credit_table(self, selenium): assert self.tbody2textlist(table) == [ [ 'CreditOne', '-$952.06 (13 hours ago)', '$2,000.00', - '$1,047.94', '$222.22', '$825.72' + '$1,047.94', '$544.54', '$503.40' ], [ 'CreditTwo', '-$5,498.65 (a day ago)', '$5,500.00', '$1.35', diff --git a/biweeklybudget/tests/acceptance/flaskapp/views/test_budgets.py b/biweeklybudget/tests/acceptance/flaskapp/views/test_budgets.py index 428fd01f..28c6286c 100644 --- a/biweeklybudget/tests/acceptance/flaskapp/views/test_budgets.py +++ b/biweeklybudget/tests/acceptance/flaskapp/views/test_budgets.py @@ -595,7 +595,7 @@ def test_1_verify_db(self, testdb): max_t = max([ t.id for t in testdb.query(Transaction).all() ]) - assert max_t == 3 + assert max_t == 4 max_r = max([ t.id for t in testdb.query(TxnReconcile).all() ]) @@ -684,7 +684,7 @@ def test_2_transfer_modal(self, base_url, selenium): _, _, body = self.get_modal_parts(selenium) x = body.find_elements_by_tag_name('div')[0] assert 'alert-success' in x.get_attribute('class') - assert x.text.strip() == 'Successfully saved Transactions 4 and 5' \ + assert x.text.strip() == 'Successfully saved Transactions 5 and 6' \ ' in database.' # dismiss the modal selenium.find_element_by_id('modalCloseButton').click() @@ -700,7 +700,7 @@ def test_2_transfer_modal(self, base_url, selenium): def test_3_verify_db(self, testdb): desc = 'Budget Transfer - 123.45 from Periodic2 (2) to Standing2 (5)' - t1 = testdb.query(Transaction).get(4) + t1 = testdb.query(Transaction).get(5) assert t1.date == dtnow().date() assert t1.actual_amount == Decimal('123.45') assert t1.budgeted_amount == Decimal('123.45') @@ -712,11 +712,11 @@ def test_3_verify_db(self, testdb): assert t1.budget_transactions[0].budget_id == 2 assert t1.budget_transactions[0].amount == Decimal('123.45') rec1 = testdb.query(TxnReconcile).get(2) - assert rec1.txn_id == 4 + assert rec1.txn_id == 5 assert rec1.ofx_fitid is None assert rec1.ofx_account_id is None assert rec1.note == desc - t2 = testdb.query(Transaction).get(5) + t2 = testdb.query(Transaction).get(6) assert t2.date == dtnow().date() assert t2.actual_amount == Decimal('-123.45') assert t2.budgeted_amount == Decimal('-123.45') @@ -728,7 +728,7 @@ def test_3_verify_db(self, testdb): assert t2.budget_transactions[0].budget_id == 5 assert t2.budget_transactions[0].amount == Decimal('-123.45') rec2 = testdb.query(TxnReconcile).get(3) - assert rec2.txn_id == 5 + assert rec2.txn_id == 6 assert rec2.ofx_fitid is None assert rec2.ofx_account_id is None assert rec2.note == desc @@ -743,7 +743,7 @@ def test_1_verify_db(self, testdb): max_t = max([ t.id for t in testdb.query(Transaction).all() ]) - assert max_t == 3 + assert max_t == 4 max_r = max([ t.id for t in testdb.query(TxnReconcile).all() ]) @@ -838,7 +838,7 @@ def test_2_transfer_modal(self, base_url, selenium, testdb): _, _, body = self.get_modal_parts(selenium) x = body.find_elements_by_tag_name('div')[0] assert 'alert-success' in x.get_attribute('class') - assert x.text.strip() == 'Successfully saved Transactions 4 and 5' \ + assert x.text.strip() == 'Successfully saved Transactions 5 and 6' \ ' in database.' # dismiss the modal selenium.find_element_by_id('modalCloseButton').click() @@ -862,7 +862,7 @@ def test_3_verify_db(self, testdb): assert pp.budget_sums[2]['spent'] == Decimal('98.77') assert pp.budget_sums[2]['trans_total'] == Decimal('98.77') desc = 'Budget Transfer - 123.45 from Standing2 (5) to Periodic2 (2)' - t1 = testdb.query(Transaction).get(4) + t1 = testdb.query(Transaction).get(5) assert t1.date == dtnow().date() assert t1.actual_amount == Decimal('123.45') assert t1.budgeted_amount == Decimal('123.45') @@ -874,11 +874,11 @@ def test_3_verify_db(self, testdb): assert t1.budget_transactions[0].budget_id == 5 assert t1.budget_transactions[0].amount == Decimal('123.45') rec1 = testdb.query(TxnReconcile).get(2) - assert rec1.txn_id == 4 + assert rec1.txn_id == 5 assert rec1.ofx_fitid is None assert rec1.ofx_account_id is None assert rec1.note == desc - t2 = testdb.query(Transaction).get(5) + t2 = testdb.query(Transaction).get(6) assert t2.date == dtnow().date() assert t2.actual_amount == Decimal('-123.45') assert t2.budgeted_amount == Decimal('-123.45') @@ -890,7 +890,7 @@ def test_3_verify_db(self, testdb): assert t2.budget_transactions[0].budget_id == 2 assert t2.budget_transactions[0].amount == Decimal('-123.45') rec2 = testdb.query(TxnReconcile).get(3) - assert rec2.txn_id == 5 + assert rec2.txn_id == 6 assert rec2.ofx_fitid is None assert rec2.ofx_account_id is None assert rec2.note == desc diff --git a/biweeklybudget/tests/acceptance/flaskapp/views/test_fuel.py b/biweeklybudget/tests/acceptance/flaskapp/views/test_fuel.py index 453ebdf4..1ef26f2b 100644 --- a/biweeklybudget/tests/acceptance/flaskapp/views/test_fuel.py +++ b/biweeklybudget/tests/acceptance/flaskapp/views/test_fuel.py @@ -410,8 +410,8 @@ def test_10_fuel_verify_db(self, testdb): trans_ids = [ x.id for x in testdb.query(Transaction).all() ] - assert len(trans_ids) == 3 - assert max(trans_ids) == 3 + assert len(trans_ids) == 4 + assert max(trans_ids) == 4 def test_11_fuel_populate_modal(self, base_url, selenium): self.get(selenium, base_url + '/fuel') @@ -584,8 +584,8 @@ def test_13_fuel_verify_db(self, testdb): trans_ids = [ x.id for x in testdb.query(Transaction).all() ] - assert len(trans_ids) == 3 - assert max(trans_ids) == 3 + assert len(trans_ids) == 4 + assert max(trans_ids) == 4 def test_14_fuel_add_with_trans(self, base_url, selenium): self.get(selenium, base_url + '/fuel') @@ -648,7 +648,7 @@ def test_14_fuel_add_with_trans(self, base_url, selenium): x = body.find_elements_by_tag_name('div')[0] assert 'alert-success' in x.get_attribute('class') assert x.text.strip() == 'Successfully saved FuelFill 8 ' \ - 'and Transaction 4 in database.' + 'and Transaction 5 in database.' # dismiss the modal selenium.find_element_by_id('modalCloseButton').click() self.wait_for_jquery_done(selenium) @@ -686,9 +686,9 @@ def test_15_fuel_verify_db(self, testdb): trans_ids = [ x.id for x in testdb.query(Transaction).all() ] - assert len(trans_ids) == 4 - assert max(trans_ids) == 4 - trans = testdb.query(Transaction).get(4) + assert len(trans_ids) == 5 + assert max(trans_ids) == 5 + trans = testdb.query(Transaction).get(5) assert trans.date == (dtnow() - timedelta(days=2)).date() assert trans.actual_amount == Decimal('14.82') assert trans.budgeted_amount is None diff --git a/biweeklybudget/tests/acceptance/flaskapp/views/test_index.py b/biweeklybudget/tests/acceptance/flaskapp/views/test_index.py index 53c55383..8d402ec9 100644 --- a/biweeklybudget/tests/acceptance/flaskapp/views/test_index.py +++ b/biweeklybudget/tests/acceptance/flaskapp/views/test_index.py @@ -121,7 +121,7 @@ def test_credit_table(self, selenium): 'Account', 'Balance', 'Available', 'Avail - Unrec' ] assert self.tbody2textlist(table) == [ - ['CreditOne', '-$952.06 (13 hours ago)', '$1,047.94', '$825.72'], + ['CreditOne', '-$952.06 (13 hours ago)', '$1,047.94', '$503.40'], ['CreditTwo', '-$5,498.65 (a day ago)', '$1.35', '$1.35'] ] links = [] diff --git a/biweeklybudget/tests/acceptance/flaskapp/views/test_payperiods.py b/biweeklybudget/tests/acceptance/flaskapp/views/test_payperiods.py index 560a75f5..b10d2ae3 100644 --- a/biweeklybudget/tests/acceptance/flaskapp/views/test_payperiods.py +++ b/biweeklybudget/tests/acceptance/flaskapp/views/test_payperiods.py @@ -833,7 +833,7 @@ def test_00_inactivate_scheduled(self, testdb): # delete existing transactions for tr in testdb.query(TxnReconcile).all(): testdb.delete(tr) - for idx in [1, 2, 3]: + for idx in [1, 2, 3, 4]: t = testdb.query(Transaction).get(idx) testdb.delete(t) testdb.flush() @@ -1039,7 +1039,7 @@ def test_07_transaction_table(self, base_url, selenium, testdb): [ ppdate.strftime('%Y-%m-%d'), '$232.22', - 'T3 (7)', + 'T3 (8)', 'CreditOne', 'Periodic2 ($222.22)
' 'Periodic1 ($10.00)', @@ -1049,7 +1049,7 @@ def test_07_transaction_table(self, base_url, selenium, testdb): [ (ppdate + timedelta(days=2)).strftime('%Y-%m-%d'), '-$333.33', - 'T2 (6)', + 'T2 (7)', 'BankTwoStale', 'Standing1', '(from 3)' @@ -1073,7 +1073,7 @@ def test_07_transaction_table(self, base_url, selenium, testdb): [ (ppdate + timedelta(days=6)).strftime('%Y-%m-%d'), '$111.13', - 'T1foo (5)', + 'T1foo (6)', 'BankOne', 'Periodic1', '(from 1)' @@ -1097,8 +1097,8 @@ def test_07_transaction_table(self, base_url, selenium, testdb): [ (pp.start_date + timedelta(days=8)).strftime('%Y-%m-%d'), '$12.00', - 'Txn From ST7' - ' (4)', + 'Txn From ST7' + ' (5)', 'BankOne', 'Periodic1', '(from 7)' @@ -1114,13 +1114,13 @@ def test_08_transaction_modal(self, base_url, selenium, testdb): base_url + '/payperiod/' + PAY_PERIOD_START_DATE.strftime('%Y-%m-%d') ) - link = selenium.find_element_by_xpath('//a[text()="T1foo (5)"]') + link = selenium.find_element_by_xpath('//a[text()="T1foo (6)"]') link.click() modal, title, body = self.get_modal_parts(selenium) self.assert_modal_displayed(modal, title, body) - assert title.text == 'Edit Transaction 5' + assert title.text == 'Edit Transaction 6' assert body.find_element_by_id( - 'trans_frm_id').get_attribute('value') == '5' + 'trans_frm_id').get_attribute('value') == '6' assert body.find_element_by_id( 'trans_frm_date').get_attribute('value') == ( pp.start_date + timedelta(days=6)).strftime('%Y-%m-%d') @@ -1166,13 +1166,13 @@ def test_09_transaction_modal_edit(self, base_url, selenium, testdb): base_url + '/payperiod/' + PAY_PERIOD_START_DATE.strftime('%Y-%m-%d') ) - link = selenium.find_element_by_xpath('//a[text()="T1foo (5)"]') + link = selenium.find_element_by_xpath('//a[text()="T1foo (6)"]') link.click() modal, title, body = self.get_modal_parts(selenium) self.assert_modal_displayed(modal, title, body) - assert title.text == 'Edit Transaction 5' + assert title.text == 'Edit Transaction 6' assert body.find_element_by_id( - 'trans_frm_id').get_attribute('value') == '5' + 'trans_frm_id').get_attribute('value') == '6' desc = body.find_element_by_id('trans_frm_description') desc.send_keys('edited') # submit the form @@ -1182,7 +1182,7 @@ def test_09_transaction_modal_edit(self, base_url, selenium, testdb): _, _, body = self.get_modal_parts(selenium) x = body.find_elements_by_tag_name('div')[0] assert 'alert-success' in x.get_attribute('class') - assert x.text.strip() == 'Successfully saved Transaction 5 ' \ + assert x.text.strip() == 'Successfully saved Transaction 6 ' \ 'in database.' # dismiss the modal selenium.find_element_by_id('modalCloseButton').click() @@ -1190,11 +1190,11 @@ def test_09_transaction_modal_edit(self, base_url, selenium, testdb): # test that updated budget was removed from the page table = selenium.find_element_by_id('trans-table') texts = [y[2] for y in self.tbody2textlist(table)] - assert 'T1fooedited (5)' in texts + assert 'T1fooedited (6)' in texts def test_10_transaction_modal_verify_db(self, testdb): pp = BiweeklyPayPeriod(PAY_PERIOD_START_DATE, testdb) - t = testdb.query(Transaction).get(5) + t = testdb.query(Transaction).get(6) assert t is not None assert t.description == 'T1fooedited' assert t.date == (pp.start_date + timedelta(days=6)) @@ -1359,7 +1359,7 @@ def test_20_issue152_active_budget(self, base_url, selenium): _, _, body = self.get_modal_parts(selenium) x = body.find_elements_by_tag_name('div')[0] assert 'alert-success' in x.get_attribute('class') - assert x.text.strip() == 'Successfully saved Transaction 8 ' \ + assert x.text.strip() == 'Successfully saved Transaction 9 ' \ 'in database.' # dismiss the modal selenium.find_element_by_id('modalCloseButton').click() @@ -1367,11 +1367,11 @@ def test_20_issue152_active_budget(self, base_url, selenium): # test that updated budget was removed from the page table = selenium.find_element_by_id('trans-table') texts = [y[2] for y in self.tbody2textlist(table)] - assert 'issue152regression1 (8)' in texts + assert 'issue152regression1 (9)' in texts def test_21_issue152_verify_db(self, testdb): """verify the transaction we added""" - t1 = testdb.query(Transaction).get(8) + t1 = testdb.query(Transaction).get(9) assert t1.date == (dtnow() - timedelta(days=2)).date() assert t1.actual_amount == Decimal('100.00') assert t1.budgeted_amount is None @@ -1525,7 +1525,7 @@ def test_30_issue152_inactive_budget(self, testdb): ) testdb.add(trans) testdb.commit() - t1 = testdb.query(Transaction).get(9) + t1 = testdb.query(Transaction).get(10) assert t1.date == (dtnow() - timedelta(days=1)).date() assert t1.actual_amount == Decimal('200.00') assert t1.budgeted_amount is None @@ -1545,14 +1545,14 @@ def test_31_issue152_edit_inactive(self, base_url, selenium): PAY_PERIOD_START_DATE.strftime('%Y-%m-%d') ) link = selenium.find_element_by_xpath( - '//a[text()="issue152regression3 (9)"]' + '//a[text()="issue152regression3 (10)"]' ) link.click() modal, title, body = self.get_modal_parts(selenium) self.assert_modal_displayed(modal, title, body) - assert title.text == 'Edit Transaction 9' + assert title.text == 'Edit Transaction 10' assert body.find_element_by_id( - 'trans_frm_id').get_attribute('value') == '9' + 'trans_frm_id').get_attribute('value') == '10' desc = body.find_element_by_id('trans_frm_description') desc.send_keys('-edited') # submit the form @@ -1562,7 +1562,7 @@ def test_31_issue152_edit_inactive(self, base_url, selenium): _, _, body = self.get_modal_parts(selenium) x = body.find_elements_by_tag_name('div')[0] assert 'alert-success' in x.get_attribute('class') - assert x.text.strip() == 'Successfully saved Transaction 9 ' \ + assert x.text.strip() == 'Successfully saved Transaction 10 ' \ 'in database.' # dismiss the modal selenium.find_element_by_id('modalCloseButton').click() @@ -1570,10 +1570,10 @@ def test_31_issue152_edit_inactive(self, base_url, selenium): # test that updated budget was removed from the page table = selenium.find_element_by_id('trans-table') texts = [y[2] for y in self.tbody2textlist(table)] - assert 'issue152regression3-edited (9)' in texts + assert 'issue152regression3-edited (10)' in texts def test_32_issue152_verify_db(self, testdb): - t1 = testdb.query(Transaction).get(9) + t1 = testdb.query(Transaction).get(10) assert t1.date == (dtnow() - timedelta(days=1)).date() assert t1.actual_amount == Decimal('200.00') assert t1.budgeted_amount is None @@ -1836,7 +1836,7 @@ def test_05_modal_schedtrans_to_trans(self, base_url, selenium, testdb): _, _, body = self.get_modal_parts(selenium) x = body.find_elements_by_tag_name('div')[0] assert 'alert-success' in x.get_attribute('class') - assert x.text.strip() == 'Successfully created Transaction 6 for ' \ + assert x.text.strip() == 'Successfully created Transaction 7 for ' \ 'ScheduledTransaction 7.' # dismiss the modal selenium.find_element_by_id('modalCloseButton').click() @@ -1846,7 +1846,7 @@ def test_05_modal_schedtrans_to_trans(self, base_url, selenium, testdb): texts = self.tbody2textlist(table) # sort order changes when we make this active assert texts[0][2] == '(sched) ST7 per_period (7)' - assert texts[1][2] == 'ST7 per_period Trans (6)' + assert texts[1][2] == 'ST7 per_period Trans (7)' def test_06_verify_db(self, testdb): t = testdb.query(ScheduledTransaction).get(7) @@ -1861,7 +1861,7 @@ def test_06_verify_db(self, testdb): assert t.notes is None assert t.is_active is True pp = BiweeklyPayPeriod(PAY_PERIOD_START_DATE, testdb) - t = testdb.query(Transaction).get(6) + t = testdb.query(Transaction).get(7) assert t is not None assert t.description == 'ST7 per_period Trans' assert t.date == (pp.start_date + timedelta(days=2)) @@ -1893,7 +1893,7 @@ def test_00_inactivate_scheduled(self, testdb): # delete existing transactions for tr in testdb.query(TxnReconcile).all(): testdb.delete(tr) - for idx in [1, 2, 3]: + for idx in [1, 2, 3, 4]: t = testdb.query(Transaction).get(idx) testdb.delete(t) testdb.flush() @@ -2084,7 +2084,7 @@ def test_06_transaction_table(self, base_url, selenium, testdb): [ ppdate.strftime('%Y-%m-%d'), '$222.22', - 'T3 (7)', + 'T3 (8)', 'CreditOne', 'Periodic2', ' ', @@ -2093,7 +2093,7 @@ def test_06_transaction_table(self, base_url, selenium, testdb): [ (ppdate + timedelta(days=2)).strftime('%Y-%m-%d'), '-$333.33', - 'T2 (6)', + 'T2 (7)', 'BankTwoStale', 'Standing1', '(from 3)' @@ -2117,7 +2117,7 @@ def test_06_transaction_table(self, base_url, selenium, testdb): [ (ppdate + timedelta(days=6)).strftime('%Y-%m-%d'), '$111.13', - 'T1foo (5)', + 'T1foo (6)', 'BankOne', 'Periodic1', '(from 1)' @@ -2141,8 +2141,8 @@ def test_06_transaction_table(self, base_url, selenium, testdb): [ (pp.start_date + timedelta(days=8)).strftime('%Y-%m-%d'), '$12.00', - 'Txn From ST7' - ' (4)', + 'Txn From ST7' + ' (5)', 'BankOne', 'Periodic1', '(from 7)' @@ -2155,7 +2155,7 @@ def test_07_verify_db_ids(self, testdb): max_t = max([ t.id for t in testdb.query(Transaction).all() ]) - assert max_t == 7 + assert max_t == 8 max_r = max([ t.id for t in testdb.query(TxnReconcile).all() ]) @@ -2240,7 +2240,7 @@ def test_08_budget_transfer(self, base_url, selenium, testdb): _, _, body = self.get_modal_parts(selenium) x = body.find_elements_by_tag_name('div')[0] assert 'alert-success' in x.get_attribute('class') - assert x.text.strip() == 'Successfully saved Transactions 8 and 9' \ + assert x.text.strip() == 'Successfully saved Transactions 9 and 10' \ ' in database.' # dismiss the modal selenium.find_element_by_id('modalCloseButton').click() @@ -2249,7 +2249,7 @@ def test_08_budget_transfer(self, base_url, selenium, testdb): def test_10_verify_db(self, testdb): desc = 'Budget Transfer - 123.45 from Periodic2 (2) to Standing2 (5)' - t1 = testdb.query(Transaction).get(8) + t1 = testdb.query(Transaction).get(9) assert t1.date == dtnow().date() assert t1.actual_amount == Decimal('123.45') assert t1.budgeted_amount == Decimal('123.45') @@ -2262,11 +2262,11 @@ def test_10_verify_db(self, testdb): assert t1.budget_transactions[0].budget_id == 2 assert t1.budget_transactions[0].amount == Decimal('123.45') rec1 = testdb.query(TxnReconcile).get(3) - assert rec1.txn_id == 8 + assert rec1.txn_id == 9 assert rec1.ofx_fitid is None assert rec1.ofx_account_id is None assert rec1.note == desc - t2 = testdb.query(Transaction).get(9) + t2 = testdb.query(Transaction).get(10) assert t2.date == dtnow().date() assert t2.actual_amount == Decimal('-123.45') assert t2.budgeted_amount == Decimal('-123.45') @@ -2279,7 +2279,7 @@ def test_10_verify_db(self, testdb): assert t2.budget_transactions[0].budget_id == 5 assert t2.budget_transactions[0].amount == Decimal('-123.45') rec2 = testdb.query(TxnReconcile).get(4) - assert rec2.txn_id == 9 + assert rec2.txn_id == 10 assert rec2.ofx_fitid is None assert rec2.ofx_account_id is None assert rec2.note == desc @@ -2389,7 +2389,7 @@ def test_16_transaction_table(self, base_url, selenium, testdb): [ ppdate.strftime('%Y-%m-%d'), '$222.22', - 'T3 (7)', + 'T3 (8)', 'CreditOne', 'Periodic2', ' ', @@ -2398,7 +2398,7 @@ def test_16_transaction_table(self, base_url, selenium, testdb): [ (ppdate + timedelta(days=2)).strftime('%Y-%m-%d'), '-$333.33', - 'T2 (6)', + 'T2 (7)', 'BankTwoStale', 'Standing1', '(from 3)' @@ -2422,7 +2422,7 @@ def test_16_transaction_table(self, base_url, selenium, testdb): [ (ppdate + timedelta(days=6)).strftime('%Y-%m-%d'), '$111.13', - 'T1foo (5)', + 'T1foo (6)', 'BankOne', 'Periodic1', '(from 1)' @@ -2446,8 +2446,8 @@ def test_16_transaction_table(self, base_url, selenium, testdb): [ (pp.start_date + timedelta(days=8)).strftime('%Y-%m-%d'), '$12.00', - 'Txn From ST7' - ' (4)', + 'Txn From ST7' + ' (5)', 'BankOne', 'Periodic1', '(from 7)' @@ -2457,9 +2457,9 @@ def test_16_transaction_table(self, base_url, selenium, testdb): [ dtnow().date().strftime('%Y-%m-%d'), '$123.45', - '' + '' 'Budget Transfer - 123.45 from Periodic2 (2) to ' - 'Standing2 (5) (8)', + 'Standing2 (5) (9)', 'BankOne', 'Periodic2', ' ', @@ -2468,9 +2468,9 @@ def test_16_transaction_table(self, base_url, selenium, testdb): [ dtnow().date().strftime('%Y-%m-%d'), '-$123.45', - '' + '' 'Budget Transfer - 123.45 from Periodic2 (2) to ' - 'Standing2 (5) (9)', + 'Standing2 (5) (10)', 'BankOne', 'Standing2', ' ', @@ -2545,7 +2545,7 @@ def test_00_inactivate_scheduled(self, testdb): # delete existing transactions for tr in testdb.query(TxnReconcile).all(): testdb.delete(tr) - for idx in [1, 2, 3]: + for idx in [1, 2, 3, 4]: t = testdb.query(Transaction).get(idx) testdb.delete(t) testdb.flush() @@ -2736,7 +2736,7 @@ def test_06_transaction_table(self, base_url, selenium, testdb): [ ppdate.strftime('%Y-%m-%d'), '$222.22', - 'T3 (7)', + 'T3 (8)', 'CreditOne', 'Periodic2', ' ', @@ -2745,7 +2745,7 @@ def test_06_transaction_table(self, base_url, selenium, testdb): [ (ppdate + timedelta(days=2)).strftime('%Y-%m-%d'), '-$333.33', - 'T2 (6)', + 'T2 (7)', 'BankTwoStale', 'Standing1', '(from 3)' @@ -2769,7 +2769,7 @@ def test_06_transaction_table(self, base_url, selenium, testdb): [ (ppdate + timedelta(days=6)).strftime('%Y-%m-%d'), '$111.13', - 'T1foo (5)', + 'T1foo (6)', 'BankOne', 'Periodic1', '(from 1)' @@ -2793,8 +2793,8 @@ def test_06_transaction_table(self, base_url, selenium, testdb): [ (pp.start_date + timedelta(days=8)).strftime('%Y-%m-%d'), '$12.00', - 'Txn From ST7' - ' (4)', + 'Txn From ST7' + ' (5)', 'BankOne', 'Periodic1', '(from 7)' @@ -2807,7 +2807,7 @@ def test_07_verify_db_ids(self, testdb): max_t = max([ t.id for t in testdb.query(Transaction).all() ]) - assert max_t == 7 + assert max_t == 8 max_r = max([ t.id for t in testdb.query(TxnReconcile).all() ]) @@ -2877,7 +2877,7 @@ def test_08_budget_transfer(self, base_url, selenium, testdb): _, _, body = self.get_modal_parts(selenium) x = body.find_elements_by_tag_name('div')[0] assert 'alert-success' in x.get_attribute('class') - assert x.text.strip() == 'Successfully created Transaction 8 to' \ + assert x.text.strip() == 'Successfully created Transaction 9 to' \ ' skip ScheduledTransaction 8.' # dismiss the modal selenium.find_element_by_id('modalCloseButton').click() @@ -2888,7 +2888,7 @@ def test_10_verify_db(self, testdb): pp = BiweeklyPayPeriod(PAY_PERIOD_START_DATE, testdb) desc = 'Skip ScheduledTransaction 8 in period %s' % \ pp.start_date.strftime('%Y-%m-%d') - t1 = testdb.query(Transaction).get(8) + t1 = testdb.query(Transaction).get(9) assert t1.date == pp.start_date assert t1.actual_amount == Decimal('0.0') assert t1.budgeted_amount == Decimal('0.0') @@ -2901,7 +2901,7 @@ def test_10_verify_db(self, testdb): assert t1.budget_transactions[0].budget_id == 1 assert t1.budget_transactions[0].amount == Decimal('0.0') rec1 = testdb.query(TxnReconcile).get(3) - assert rec1.txn_id == 8 + assert rec1.txn_id == 9 assert rec1.ofx_fitid is None assert rec1.ofx_account_id is None assert rec1.note == desc @@ -3007,7 +3007,7 @@ def test_16_transaction_table(self, base_url, selenium, testdb): [ ppdate.strftime('%Y-%m-%d'), '$222.22', - 'T3 (7)', + 'T3 (8)', 'CreditOne', 'Periodic2', ' ', @@ -3016,8 +3016,8 @@ def test_16_transaction_table(self, base_url, selenium, testdb): [ ppdate.strftime('%Y-%m-%d'), '$0.00', - 'Skip ' - 'ScheduledTransaction 8 in period %s (8)' % ( + 'Skip ' + 'ScheduledTransaction 8 in period %s (9)' % ( pp.start_date.strftime('%Y-%m-%d') ), 'BankOne', @@ -3029,7 +3029,7 @@ def test_16_transaction_table(self, base_url, selenium, testdb): [ (ppdate + timedelta(days=2)).strftime('%Y-%m-%d'), '-$333.33', - 'T2 (6)', + 'T2 (7)', 'BankTwoStale', 'Standing1', '(from 3)' @@ -3039,7 +3039,7 @@ def test_16_transaction_table(self, base_url, selenium, testdb): [ (ppdate + timedelta(days=6)).strftime('%Y-%m-%d'), '$111.13', - 'T1foo (5)', + 'T1foo (6)', 'BankOne', 'Periodic1', '(from 1)' @@ -3063,8 +3063,8 @@ def test_16_transaction_table(self, base_url, selenium, testdb): [ (pp.start_date + timedelta(days=8)).strftime('%Y-%m-%d'), '$12.00', - 'Txn From ST7' - ' (4)', + 'Txn From ST7' + ' (5)', 'BankOne', 'Periodic1', '(from 7)' diff --git a/biweeklybudget/tests/acceptance/flaskapp/views/test_transactions.py b/biweeklybudget/tests/acceptance/flaskapp/views/test_transactions.py index f6acbe6c..59091c25 100644 --- a/biweeklybudget/tests/acceptance/flaskapp/views/test_transactions.py +++ b/biweeklybudget/tests/acceptance/flaskapp/views/test_transactions.py @@ -117,6 +117,16 @@ def test_table(self, selenium): '', '', '' + ], + [ + (self.dt - timedelta(days=35)).date().strftime('%Y-%m-%d'), + '$322.32', + 'T4split', + 'CreditOne (3)', + 'Periodic2 (2)', + '', + '', + '' ] ] linkcols = [ @@ -172,7 +182,8 @@ def test_acct_filter(self, selenium): p1trans = [ 'T1foo', 'T2', - 'T3' + 'T3', + 'T4split' ] self.get(selenium, self.baseurl + '/transactions') table = self.retry_stale( @@ -225,7 +236,8 @@ def test_budg_filter(self, selenium): p1trans = [ 'T1foo', 'T2', - 'T3' + 'T3', + 'T4split' ] self.get(selenium, self.baseurl + '/transactions') table = self.retry_stale( @@ -245,7 +257,7 @@ def test_budg_filter(self, selenium): ) texts = self.retry_stale(self.tbody2textlist, table) trans = [t[2] for t in texts] - assert trans == ['T3'] + assert trans == ['T3', 'T4split'] # select Standing1 (4) budg_filter.select_by_value('4') table = self.retry_stale( @@ -592,7 +604,7 @@ def test_22_modal_add(self, base_url, selenium): amt.clear() amt.send_keys('123.45') desc = body.find_element_by_id('trans_frm_description') - desc.send_keys('NewTrans4') + desc.send_keys('NewTrans5') acct_sel = Select(body.find_element_by_id('trans_frm_account')) assert acct_sel.first_selected_option.get_attribute('value') == '1' acct_sel.select_by_value('1') @@ -607,7 +619,7 @@ def test_22_modal_add(self, base_url, selenium): _, _, body = self.get_modal_parts(selenium) x = body.find_elements_by_tag_name('div')[0] assert 'alert-success' in x.get_attribute('class') - assert x.text.strip() == 'Successfully saved Transaction 4 ' \ + assert x.text.strip() == 'Successfully saved Transaction 5 ' \ 'in database.' # dismiss the modal selenium.find_element_by_id('modalCloseButton').click() @@ -615,12 +627,12 @@ def test_22_modal_add(self, base_url, selenium): # test that new trans was added to the table table = selenium.find_element_by_id('table-transactions') texts = [y[2] for y in self.tbody2textlist(table)] - assert 'NewTrans4' in texts + assert 'NewTrans5' in texts def test_23_modal_add_verify_db(self, testdb): - t = testdb.query(Transaction).get(4) + t = testdb.query(Transaction).get(5) assert t is not None - assert t.description == 'NewTrans4' + assert t.description == 'NewTrans5' dnow = dtnow() assert t.date == date(year=dnow.year, month=dnow.month, day=15) assert t.actual_amount == Decimal('123.45') @@ -660,7 +672,7 @@ def test_32_modal_add(self, base_url, selenium): amt.clear() amt.send_keys('345.67') desc = body.find_element_by_id('trans_frm_description') - desc.send_keys('NewTrans5') + desc.send_keys('NewTrans6') acct_sel = Select(body.find_element_by_id('trans_frm_account')) assert acct_sel.first_selected_option.get_attribute('value') == '1' acct_sel.select_by_value('1') @@ -675,7 +687,7 @@ def test_32_modal_add(self, base_url, selenium): _, _, body = self.get_modal_parts(selenium) x = body.find_elements_by_tag_name('div')[0] assert 'alert-success' in x.get_attribute('class') - assert x.text.strip() == 'Successfully saved Transaction 5 ' \ + assert x.text.strip() == 'Successfully saved Transaction 6 ' \ 'in database.' # dismiss the modal selenium.find_element_by_id('modalCloseButton').click() @@ -683,12 +695,12 @@ def test_32_modal_add(self, base_url, selenium): # test that new trans was added to the table table = selenium.find_element_by_id('table-transactions') texts = [y[2] for y in self.tbody2textlist(table)] - assert 'NewTrans5' in texts + assert 'NewTrans6' in texts def test_33_verify_db(self, testdb): - t = testdb.query(Transaction).get(5) + t = testdb.query(Transaction).get(6) assert t is not None - assert t.description == 'NewTrans5' + assert t.description == 'NewTrans6' assert t.date == dtnow().date() assert t.actual_amount == Decimal('345.67') assert t.budgeted_amount is None @@ -721,13 +733,13 @@ def test_41_modal_edit_change_between_standing(self, base_url, selenium): """ self.baseurl = base_url self.get(selenium, base_url + '/transactions') - link = selenium.find_element_by_xpath('//a[text()="NewTrans5"]') + link = selenium.find_element_by_xpath('//a[text()="NewTrans6"]') link.click() modal, title, body = self.get_modal_parts(selenium) self.assert_modal_displayed(modal, title, body) - assert title.text == 'Edit Transaction 5' + assert title.text == 'Edit Transaction 6' assert body.find_element_by_id( - 'trans_frm_id').get_attribute('value') == '5' + 'trans_frm_id').get_attribute('value') == '6' amt = body.find_element_by_id('trans_frm_amount') assert amt.get_attribute('value') == '345.67' budget_sel = Select(body.find_element_by_id('trans_frm_budget')) @@ -740,15 +752,15 @@ def test_41_modal_edit_change_between_standing(self, base_url, selenium): _, _, body = self.get_modal_parts(selenium) x = body.find_elements_by_tag_name('div')[0] assert 'alert-success' in x.get_attribute('class') - assert x.text.strip() == 'Successfully saved Transaction 5 ' \ + assert x.text.strip() == 'Successfully saved Transaction 6 ' \ 'in database.' # dismiss the modal selenium.find_element_by_id('modalCloseButton').click() def test_42_simple_modal_verify_db(self, testdb): - t = testdb.query(Transaction).get(5) + t = testdb.query(Transaction).get(6) assert t is not None - assert t.description == 'NewTrans5' + assert t.description == 'NewTrans6' assert t.date == dtnow().date() assert t.actual_amount == Decimal('345.67') assert t.budgeted_amount is None diff --git a/biweeklybudget/tests/acceptance/test_biweeklypayperiod.py b/biweeklybudget/tests/acceptance/test_biweeklypayperiod.py index 93c63939..e64369c6 100644 --- a/biweeklybudget/tests/acceptance/test_biweeklypayperiod.py +++ b/biweeklybudget/tests/acceptance/test_biweeklypayperiod.py @@ -343,149 +343,149 @@ def test_3_ignore_scheduled_converted_to_real_trans(self, testdb): ) assert pp.start_date == date(2017, 4, 7) all_trans = pp.transactions_list + from pprint import pprint + pprint(all_trans) assert all_trans == [ { 'account_id': 1, 'account_name': 'BankOne', - 'amount': Decimal('222.22'), + 'amount': Decimal('222.2200'), + 'budgeted_amount': None, 'budgets': { - 1: {'name': 'Periodic1', 'amount': Decimal('222.22')} + 1: {'amount': Decimal('222.2200'), 'name': 'Periodic1'} }, - 'budgeted_amount': None, 'date': None, 'description': 'ST_pp_1', 'id': 8, + 'reconcile_id': None, 'sched_trans_id': None, 'sched_type': 'per period', - 'type': 'ScheduledTransaction', - 'reconcile_id': None + 'type': 'ScheduledTransaction' }, { 'account_id': 1, 'account_name': 'BankOne', - 'amount': Decimal('333.33'), + 'amount': Decimal('333.3300'), + 'budgeted_amount': None, 'budgets': { - 1: {'name': 'Periodic1', 'amount': Decimal('333.33')} + 1: {'amount': Decimal('333.3300'), 'name': 'Periodic1'} }, - 'budgeted_amount': None, 'date': None, 'description': 'ST_pp_3', 'id': 9, + 'reconcile_id': None, 'sched_trans_id': None, 'sched_type': 'per period', - 'type': 'ScheduledTransaction', - 'reconcile_id': None + 'type': 'ScheduledTransaction' }, { 'account_id': 1, 'account_name': 'BankOne', - 'amount': Decimal('555.55'), + 'amount': Decimal('555.5500'), + 'budgeted_amount': None, 'budgets': { - 1: {'name': 'Periodic1', 'amount': Decimal('555.55')} + 1: {'amount': Decimal('555.5500'), 'name': 'Periodic1'} }, - 'budgeted_amount': None, 'date': date(2017, 4, 8), 'description': 'Trans_foo', - 'id': 8, + 'id': 9, + 'planned_budget_id': None, + 'planned_budget_name': None, + 'reconcile_id': None, 'sched_trans_id': None, 'sched_type': None, - 'type': 'Transaction', - 'reconcile_id': None, - 'planned_budget_id': None, - 'planned_budget_name': None + 'type': 'Transaction' }, - # ST7 (ST_day_9) { 'account_id': 1, 'account_name': 'BankOne', - 'amount': Decimal('111.33'), + 'amount': Decimal('111.3300'), + 'budgeted_amount': Decimal('111.1100'), 'budgets': { - 1: {'name': 'Periodic1', 'amount': Decimal('111.33')} + 1: {'amount': Decimal('111.3300'), 'name': 'Periodic1'} }, - 'budgeted_amount': Decimal('111.11'), 'date': date(2017, 4, 9), 'description': 'Trans_ST_day_9', - 'id': 4, + 'id': 5, + 'planned_budget_id': 1, + 'planned_budget_name': 'Periodic1', + 'reconcile_id': 2, 'sched_trans_id': 7, 'sched_type': None, - 'type': 'Transaction', - 'reconcile_id': 2, - 'planned_budget_id': 1, - 'planned_budget_name': 'Periodic1' + 'type': 'Transaction' }, - # ST10 (ST_date) { 'account_id': 1, 'account_name': 'BankOne', - 'amount': Decimal('444.44'), + 'amount': Decimal('444.4400'), + 'budgeted_amount': Decimal('444.4400'), 'budgets': { - 1: {'name': 'Periodic1', 'amount': Decimal('444.44')} + 1: {'amount': Decimal('444.4400'), 'name': 'Periodic1'} }, - 'budgeted_amount': Decimal('444.44'), 'date': date(2017, 4, 12), 'description': 'Trans_ST_date', - 'id': 7, + 'id': 8, + 'planned_budget_id': 1, + 'planned_budget_name': 'Periodic1', + 'reconcile_id': None, 'sched_trans_id': 10, 'sched_type': None, - 'type': 'Transaction', - 'reconcile_id': None, - 'planned_budget_id': 1, - 'planned_budget_name': 'Periodic1' + 'type': 'Transaction' }, { 'account_id': 1, 'account_name': 'BankOne', - 'amount': Decimal('333.33'), + 'amount': Decimal('333.3300'), + 'budgeted_amount': Decimal('333.3300'), 'budgets': { - 1: {'name': 'Periodic1', 'amount': Decimal('333.33')} + 1: {'amount': Decimal('333.3300'), 'name': 'Periodic1'} }, - 'budgeted_amount': Decimal('333.33'), 'date': date(2017, 4, 14), 'description': 'Trans_ST_pp_3_A', - 'id': 5, + 'id': 6, + 'planned_budget_id': 1, + 'planned_budget_name': 'Periodic1', + 'reconcile_id': None, 'sched_trans_id': 9, 'sched_type': None, - 'type': 'Transaction', - 'reconcile_id': None, - 'planned_budget_id': 1, - 'planned_budget_name': 'Periodic1' + 'type': 'Transaction' }, { 'account_id': 1, 'account_name': 'BankOne', - 'amount': Decimal('333.33'), + 'amount': Decimal('333.3300'), + 'budgeted_amount': Decimal('333.3300'), 'budgets': { - 1: {'name': 'Periodic1', 'amount': Decimal('333.33')} + 1: {'amount': Decimal('333.3300'), 'name': 'Periodic1'} }, - 'budgeted_amount': Decimal('333.33'), 'date': date(2017, 4, 15), 'description': 'Trans_ST_pp_3_B', - 'id': 6, + 'id': 7, + 'planned_budget_id': 1, + 'planned_budget_name': 'Periodic1', + 'reconcile_id': None, 'sched_trans_id': 9, 'sched_type': None, - 'type': 'Transaction', - 'reconcile_id': None, - 'planned_budget_id': 1, - 'planned_budget_name': 'Periodic1' + 'type': 'Transaction' }, { 'account_id': 1, 'account_name': 'BankOne', - 'amount': Decimal('766.66'), + 'amount': Decimal('766.6600'), + 'budgeted_amount': None, 'budgets': { - 1: {'name': 'Periodic1', 'amount': Decimal('666.66')}, - 2: {'name': 'Periodic2', 'amount': Decimal('100.00')} + 1: {'amount': Decimal('666.6600'), 'name': 'Periodic1'}, + 2: {'amount': Decimal('100.0000'), 'name': 'Periodic2'} }, - 'budgeted_amount': None, 'date': date(2017, 4, 16), 'description': 'Trans_bar', - 'id': 9, + 'id': 10, + 'planned_budget_id': None, + 'planned_budget_name': None, + 'reconcile_id': None, 'sched_trans_id': None, 'sched_type': None, - 'type': 'Transaction', - 'reconcile_id': None, - 'planned_budget_id': None, - 'planned_budget_name': None + 'type': 'Transaction' } ] diff --git a/biweeklybudget/tests/acceptance/test_db_event_handlers.py b/biweeklybudget/tests/acceptance/test_db_event_handlers.py index cd27b9c1..a9ed9b37 100644 --- a/biweeklybudget/tests/acceptance/test_db_event_handlers.py +++ b/biweeklybudget/tests/acceptance/test_db_event_handlers.py @@ -56,7 +56,7 @@ def test_0_verify_db(self, testdb): max_t = max([ t.id for t in testdb.query(Transaction).all() ]) - assert max_t == 3 + assert max_t == 4 standing = testdb.query(Budget).get(5) assert standing.is_periodic is False assert standing.name == 'Standing2' @@ -71,8 +71,8 @@ def test_1_add_trans_periodic_budget(self, testdb): t = Transaction( budget_amounts={testdb.query(Budget).get(2): Decimal('222.22')}, budgeted_amount=Decimal('123.45'), - description='T4', - notes='notesT4', + description='T5', + notes='notesT5', account=testdb.query(Account).get(1), planned_budget=testdb.query(Budget).get(2) ) @@ -85,7 +85,7 @@ def test_2_verify_db(self, testdb): max_t = max([ t.id for t in testdb.query(Transaction).all() ]) - assert max_t == 4 + assert max_t == 5 standing = testdb.query(Budget).get(5) assert standing.is_periodic is False assert standing.name == 'Standing2' @@ -100,8 +100,8 @@ def test_3_add_trans_standing_budget(self, testdb): t = Transaction( budget_amounts={testdb.query(Budget).get(5): Decimal('222.22')}, budgeted_amount=Decimal('123.45'), - description='T5', - notes='notesT5', + description='T6', + notes='notesT6', account=testdb.query(Account).get(1), planned_budget=testdb.query(Budget).get(5) ) @@ -114,7 +114,7 @@ def test_4_verify_db(self, testdb): max_t = max([ t.id for t in testdb.query(Transaction).all() ]) - assert max_t == 5 + assert max_t == 6 standing = testdb.query(Budget).get(5) assert standing.is_periodic is False assert standing.name == 'Standing2' @@ -126,7 +126,7 @@ def test_4_verify_db(self, testdb): def test_5_edit_trans_standing_budget(self, testdb): """edit a transaction against a standing budget""" - t = testdb.query(Transaction).get(5) + t = testdb.query(Transaction).get(6) budg = testdb.query(Budget).get(5) t.set_budget_amounts({budg: Decimal('111.11')}) testdb.add(t) @@ -138,7 +138,7 @@ def test_6_verify_db(self, testdb): max_t = max([ t.id for t in testdb.query(Transaction).all() ]) - assert max_t == 5 + assert max_t == 6 standing = testdb.query(Budget).get(5) assert standing.is_periodic is False assert standing.name == 'Standing2' @@ -150,7 +150,7 @@ def test_6_verify_db(self, testdb): def test_7_edit_trans_standing_budget(self, testdb): """edit a transaction against a standing budget""" - t = testdb.query(Transaction).get(5) + t = testdb.query(Transaction).get(6) t.set_budget_amounts({testdb.query(Budget).get(5): Decimal('-111.11')}) testdb.add(t) testdb.flush() @@ -161,7 +161,7 @@ def test_8_verify_db(self, testdb): max_t = max([ t.id for t in testdb.query(Transaction).all() ]) - assert max_t == 5 + assert max_t == 6 standing = testdb.query(Budget).get(5) assert standing.is_periodic is False assert standing.name == 'Standing2' diff --git a/biweeklybudget/tests/fixtures/sampledata.py b/biweeklybudget/tests/fixtures/sampledata.py index ca19be36..538c1143 100644 --- a/biweeklybudget/tests/fixtures/sampledata.py +++ b/biweeklybudget/tests/fixtures/sampledata.py @@ -240,6 +240,16 @@ def _transactions(self): description='T3', notes='notesT3', account=self.accounts['CreditOne']['account'] + ), + Transaction( + date=(self.dt - timedelta(days=35)).date(), + budget_amounts={ + self.budgets['Periodic2']: Decimal('222.22'), + self.budgets['Periodic1']: Decimal('100.10') + }, + description='T4split', + notes='notesT4split', + account=self.accounts['CreditOne']['account'] ) ] for x in res: