Skip to content

Commit

Permalink
issue #22 - add acceptance test for current budgets view, and fix pep…
Browse files Browse the repository at this point in the history
…8 error
  • Loading branch information
jantman committed Mar 27, 2017
1 parent 82d7a13 commit 0aac5ca
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions biweeklybudget/flaskapp/templates/budgets.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- /.panel-heading -->
<div class="panel-body">
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped">
<table class="table table-bordered table-hover table-striped" id="table-periodic-budgets">
<thead>
<tr>
<th>Budget</th>
Expand Down Expand Up @@ -40,7 +40,7 @@
<!-- /.panel-heading -->
<div class="panel-body">
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped">
<table class="table table-bordered table-hover table-striped" id="table-standing-budgets">
<thead>
<tr>
<th>Budget</th>
Expand Down
4 changes: 2 additions & 2 deletions biweeklybudget/flaskapp/views/budgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class BudgetsView(MethodView):

def get(self):
standing = db_session.query(Budget).filter(
Budget.is_active == True, Budget.is_periodic == False
Budget.is_active.__eq__(True), Budget.is_periodic.__eq__(False)
).order_by(Budget.name).all()
periodic = db_session.query(Budget).filter(
Budget.is_active == True, Budget.is_periodic == True
Budget.is_active.__eq__(True), Budget.is_periodic.__eq__(True)
).order_by(Budget.name).all()
return render_template(
'budgets.html',
Expand Down
17 changes: 16 additions & 1 deletion biweeklybudget/tests/acceptance/flaskapp/views/test_budgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_page(self, base_url, selenium, testflask, testdb): # noqa

def test_heading(self, selenium):
heading = selenium.find_element_by_class_name('navbar-brand')
assert heading.text == 'OFX Transactions - BiweeklyBudget'
assert heading.text == 'Budgets - BiweeklyBudget'

def test_nav_menu(self, selenium):
ul = selenium.find_element_by_id('side-menu')
Expand All @@ -62,3 +62,18 @@ def test_notifications(self, selenium):
div = selenium.find_element_by_id('notifications-row')
assert div is not None
assert div.get_attribute('class') == 'row'

def test_initial_data(self, selenium):
ptable = selenium.find_element_by_id('table-periodic-budgets')
ptexts = self.tbody2textlist(ptable)
stable = selenium.find_element_by_id('table-standing-budgets')
stexts = self.tbody2textlist(stable)
# pelems = self.tbody2elemlist(ptable)
assert ptexts == [
['Periodic1', '$100.00'],
['Periodic2', '$234.00']
]
assert stexts == [
['Standing1', '$1,284.23'],
['Standing2', '$9,482.29']
]
7 changes: 7 additions & 0 deletions biweeklybudget/tests/fixtures/sampledata.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ def _budgets(self):
is_periodic=False,
description='S2desc',
current_balance=9482.29
),
'Standing3 Inactive': Budget(
name='Standing3 Inactive',
is_periodic=False,
description='S3desc',
current_balance=-92.29,
is_active=False
)
}
for x in res.keys():
Expand Down

0 comments on commit 0aac5ca

Please sign in to comment.