Skip to content

Commit

Permalink
issue #142 - combine some test classes that could be combined; remove…
Browse files Browse the repository at this point in the history
… class_refresh_db from some classes that don't alter DB data
  • Loading branch information
jantman committed Nov 2, 2017
1 parent fbdd00b commit 0619bb5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 77 deletions.
94 changes: 24 additions & 70 deletions biweeklybudget/tests/acceptance/flaskapp/views/test_budgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
@pytest.mark.usefixtures('refreshdb', 'testflask')
class TestBudgets(AcceptanceHelper):

@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -102,10 +102,9 @@ def test_initial_data(self, selenium):

@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
@pytest.mark.incremental
class TestEditPeriodic1(AcceptanceHelper):
class TestBudgetModals(AcceptanceHelper):

def test_0_verify_db(self, testdb):
def test_00_budget_modal_verify_db(self, testdb):
b = testdb.query(Budget).get(1)
assert b is not None
assert b.name == 'Periodic1'
Expand All @@ -115,7 +114,7 @@ def test_0_verify_db(self, testdb):
assert b.is_active is True
assert b.is_income is False

def test_1_populate_modal(self, base_url, selenium):
def test_01_budget_modal_populate_modal(self, base_url, selenium):
self.get(selenium, base_url + '/budgets')
link = selenium.find_element_by_xpath('//a[text()="Periodic1 (1)"]')
link.click()
Expand All @@ -142,7 +141,7 @@ def test_1_populate_modal(self, base_url, selenium):
assert selenium.find_element_by_id(
'budget_frm_income').is_selected() is False

def test_2_update_modal(self, base_url, selenium):
def test_02_budget_modal_update_modal(self, base_url, selenium):
# Fill in the form
self.get(selenium, base_url + '/budgets')
link = selenium.find_element_by_xpath('//a[text()="Periodic1 (1)"]')
Expand Down Expand Up @@ -183,7 +182,7 @@ def test_2_update_modal(self, base_url, selenium):
'innerHTML') == '<a href="javascript:budgetModal(1, null)">' \
'EditedPeriodic1 (1)</a>'

def test_3_verify_db(self, testdb):
def test_03_budget_modal_verify_db(self, testdb):
b = testdb.query(Budget).get(1)
assert b is not None
assert b.name == 'EditedPeriodic1'
Expand All @@ -193,12 +192,7 @@ def test_3_verify_db(self, testdb):
assert b.is_active is False
assert b.is_income is False


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
class TestEditPeriodic2(AcceptanceHelper):

def test_1_populate_modal(self, base_url, selenium):
def test_10_populate_edit_periodic_2_modal(self, base_url, selenium):
self.get(selenium, base_url + '/budgets')
link = selenium.find_element_by_xpath('//a[text()="Periodic2 (2)"]')
link.click()
Expand All @@ -225,12 +219,7 @@ def test_1_populate_modal(self, base_url, selenium):
assert selenium.find_element_by_id(
'budget_frm_income').is_selected() is False


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
class TestEditPeriodic3(AcceptanceHelper):

def test_1_populate_modal(self, base_url, selenium):
def test_11_populate_edit_periodic_3_modal(self, base_url, selenium):
self.get(selenium, base_url + '/budgets')
link = selenium.find_element_by_xpath(
'//a[text()="Periodic3 Inactive (3)"]'
Expand Down Expand Up @@ -260,12 +249,7 @@ def test_1_populate_modal(self, base_url, selenium):
assert selenium.find_element_by_id(
'budget_frm_income').is_selected() is False


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
class TestEditStanding1(AcceptanceHelper):

def test_1_populate_modal(self, base_url, selenium):
def test_12_populate_edit_standing_1_modal(self, base_url, selenium):
self.get(selenium, base_url + '/budgets')
link = selenium.find_element_by_xpath('//a[text()="Standing1 (4)"]')
link.click()
Expand All @@ -292,12 +276,7 @@ def test_1_populate_modal(self, base_url, selenium):
assert selenium.find_element_by_id(
'budget_frm_income').is_selected() is False


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
class TestEditStanding2(AcceptanceHelper):

def test_1_populate_modal(self, base_url, selenium):
def test_13_populate_edit_standing_2_modal(self, base_url, selenium):
self.get(selenium, base_url + '/budgets')
link = selenium.find_element_by_xpath('//a[text()="Standing2 (5)"]')
link.click()
Expand All @@ -324,12 +303,7 @@ def test_1_populate_modal(self, base_url, selenium):
assert selenium.find_element_by_id(
'budget_frm_income').is_selected() is False


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
class TestEditStanding3(AcceptanceHelper):

def test_1_populate_modal(self, base_url, selenium):
def test_14_populate_edit_standing_3_modal(self, base_url, selenium):
self.get(selenium, base_url + '/budgets')
link = selenium.find_element_by_xpath(
'//a[text()="Standing3 Inactive (6)"]'
Expand Down Expand Up @@ -359,12 +333,7 @@ def test_1_populate_modal(self, base_url, selenium):
assert selenium.find_element_by_id(
'budget_frm_income').is_selected() is False


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
class TestEditIncome(AcceptanceHelper):

def test_0_verify_db(self, testdb):
def test_20_income_verify_db(self, testdb):
b = testdb.query(Budget).get(7)
assert b is not None
assert b.name == 'Income'
Expand All @@ -374,7 +343,7 @@ def test_0_verify_db(self, testdb):
assert b.is_active is True
assert b.is_income is True

def test_1_populate_modal(self, base_url, selenium):
def test_21_populate_income_modal(self, base_url, selenium):
self.get(selenium, base_url + '/budgets')
link = selenium.find_element_by_xpath('//a[text()="Income (7)"]')
link.click()
Expand All @@ -400,7 +369,7 @@ def test_1_populate_modal(self, base_url, selenium):
assert selenium.find_element_by_id('budget_frm_active').is_selected()
assert selenium.find_element_by_id('budget_frm_income').is_selected()

def test_2_update_modal(self, base_url, selenium):
def test_22_update_income_modal(self, base_url, selenium):
# Fill in the form
self.get(selenium, base_url + '/budgets')
link = selenium.find_element_by_xpath('//a[text()="Income (7)"]')
Expand Down Expand Up @@ -441,7 +410,7 @@ def test_2_update_modal(self, base_url, selenium):
'EditedIncome (7)</a> ' \
'<em class="text-success">(income)</em>'

def test_3_verify_db(self, testdb):
def test_23_verify_income_db(self, testdb):
b = testdb.query(Budget).get(7)
assert b is not None
assert b.name == 'EditedIncome'
Expand All @@ -451,12 +420,7 @@ def test_3_verify_db(self, testdb):
assert b.is_active is False
assert b.is_income is True


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
class TestDirectURLPeriodic1(AcceptanceHelper):

def test_1_populate_modal(self, base_url, selenium):
def test_31_populate_direct_url_modal(self, base_url, selenium):
self.get(selenium, base_url + '/budgets/1')
modal, title, body = self.get_modal_parts(selenium)
self.assert_modal_displayed(modal, title, body)
Expand All @@ -481,12 +445,7 @@ def test_1_populate_modal(self, base_url, selenium):
assert selenium.find_element_by_id(
'budget_frm_income').is_selected() is False


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
class TestAddStandingBudget(AcceptanceHelper):

def test_2_update_modal(self, base_url, selenium):
def test_41_add_standing_modal(self, base_url, selenium):
# Fill in the form
self.get(selenium, base_url + '/budgets')
link = selenium.find_element_by_id('btn_add_budget')
Expand Down Expand Up @@ -528,7 +487,7 @@ def test_2_update_modal(self, base_url, selenium):
'innerHTML') == '<a href="javascript:budgetModal(8, null)">' \
'NewStanding (8)</a>'

def test_3_verify_db(self, testdb):
def test_41_add_standing_verify_db(self, testdb):
b = testdb.query(Budget).get(8)
assert b is not None
assert b.name == 'NewStanding'
Expand All @@ -538,12 +497,7 @@ def test_3_verify_db(self, testdb):
assert b.is_active is True
assert b.is_income is False


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
class TestAddIncomeBudget(AcceptanceHelper):

def test_2_update_modal(self, base_url, selenium):
def test_51_add_income_modal(self, base_url, selenium):
# Fill in the form
self.get(selenium, base_url + '/budgets')
link = selenium.find_element_by_id('btn_add_budget')
Expand Down Expand Up @@ -574,7 +528,7 @@ def test_2_update_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 Budget 8 in database.'
assert x.text.strip() == 'Successfully saved Budget 9 in database.'
# dismiss the modal
selenium.find_element_by_id('modalCloseButton').click()
self.wait_for_load_complete(selenium)
Expand All @@ -583,12 +537,12 @@ def test_2_update_modal(self, base_url, selenium):
stable = selenium.find_element_by_id('table-periodic-budgets')
selems = self.tbody2elemlist(stable)
assert selems[1][1].get_attribute(
'innerHTML') == '<a href="javascript:budgetModal(8, null)">' \
'NewIncome (8)</a> <em class="text-success">' \
'innerHTML') == '<a href="javascript:budgetModal(9, null)">' \
'NewIncome (9)</a> <em class="text-success">' \
'(income)</em>'

def test_3_verify_db(self, testdb):
b = testdb.query(Budget).get(8)
def test_52_add_income_verify_db(self, testdb):
b = testdb.query(Budget).get(9)
assert b is not None
assert b.name == 'NewIncome'
assert b.is_periodic is True
Expand Down
5 changes: 2 additions & 3 deletions biweeklybudget/tests/acceptance/flaskapp/views/test_ofx.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
@pytest.mark.usefixtures('refreshdb', 'testflask')
class TestOFX(AcceptanceHelper):

@pytest.fixture(autouse=True)
def get_page(self, base_url, selenium):
def test_0_get_page(self, base_url, selenium):
self.baseurl = base_url
self.get(selenium, base_url + '/ofx')

Expand Down Expand Up @@ -367,7 +366,7 @@ def test_modal_auto_displayed(self, selenium):


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
@pytest.mark.usefixtures('refreshdb', 'testflask')
@pytest.mark.incremental
class TestTransReconciledModal(AcceptanceHelper):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def test_search(self, selenium):


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
@pytest.mark.usefixtures('refreshdb', 'testflask')
class TestSchedTransModalPerPeriod(AcceptanceHelper):

def test_0_verify_db(self, testdb):
Expand Down Expand Up @@ -319,7 +319,7 @@ def test_1_modal_on_click(self, base_url, selenium):


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
@pytest.mark.usefixtures('refreshdb', 'testflask')
class TestSchedTransMonthlyURL(AcceptanceHelper):

def test_0_verify_db(self, testdb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def test_3_verify_db(self, testdb):


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
@pytest.mark.usefixtures('refreshdb', 'testflask')
class TestTransModalByURL(AcceptanceHelper):

def test_0_verify_db(self, testdb):
Expand Down Expand Up @@ -704,7 +704,7 @@ def test_4_verify_index_budgets_table(self, base_url, selenium):


@pytest.mark.acceptance
@pytest.mark.usefixtures('class_refresh_db', 'refreshdb', 'testflask')
@pytest.mark.usefixtures('refreshdb', 'testflask')
@pytest.mark.incremental
class TestTransReconciledModal(AcceptanceHelper):

Expand Down

0 comments on commit 0619bb5

Please sign in to comment.