Skip to content

Commit

Permalink
issue #49 - normalize HTML to try and resolve failures happening on T…
Browse files Browse the repository at this point in the history
…ravisCI but not locally
  • Loading branch information
jantman committed Apr 30, 2017
1 parent 4012d2d commit 9a50ae9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 24 deletions.
48 changes: 24 additions & 24 deletions biweeklybudget/tests/acceptance/flaskapp/views/test_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def test_06_transactions(self, base_url, selenium):
self.get(selenium, base_url + '/reconcile')
trans_div = selenium.find_element_by_id('trans-panel')
actual_trans = [
x.get_attribute('outerHTML')
self.normalize_html(x.get_attribute('outerHTML'))
for x in trans_div.find_elements_by_class_name('reconcile-trans')
]
expected_trans = [
Expand Down Expand Up @@ -536,7 +536,7 @@ def test_07_ofxtrans(self, base_url, selenium):
self.get(selenium, base_url + '/reconcile')
ofxtrans_div = selenium.find_element_by_id('ofx-panel')
actual_ofx = [
x.get_attribute('outerHTML')
self.normalize_html(x.get_attribute('outerHTML'))
for x in ofxtrans_div.find_elements_by_class_name('reconcile-ofx')
]
expected_ofx = [
Expand Down Expand Up @@ -608,7 +608,7 @@ def test_06_transactions(self, base_url, selenium):
self.get(selenium, base_url + '/reconcile')
trans_div = selenium.find_element_by_id('trans-panel')
actual_trans = [
x.get_attribute('outerHTML')
self.normalize_html(x.get_attribute('outerHTML'))
for x in trans_div.find_elements_by_class_name('reconcile-trans')
]
expected_trans = [
Expand Down Expand Up @@ -667,7 +667,7 @@ def test_07_ofxtrans(self, base_url, selenium):
self.get(selenium, base_url + '/reconcile')
ofxtrans_div = selenium.find_element_by_id('ofx-panel')
actual_ofx = [
x.get_attribute('outerHTML')
self.normalize_html(x.get_attribute('outerHTML'))
for x in ofxtrans_div.find_elements_by_class_name('reconcile-ofx')
]
expected_ofx = [
Expand Down Expand Up @@ -740,7 +740,7 @@ def test_09_transactions(self, base_url, selenium):
self.get(selenium, base_url + '/reconcile')
trans_div = selenium.find_element_by_id('trans-panel')
actual_trans = [
x.get_attribute('outerHTML')
self.normalize_html(x.get_attribute('outerHTML'))
for x in trans_div.find_elements_by_class_name('reconcile-trans')
]
expected_trans = [
Expand All @@ -767,7 +767,7 @@ def test_10_ofxtrans(self, base_url, selenium):
self.get(selenium, base_url + '/reconcile')
ofxtrans_div = selenium.find_element_by_id('ofx-panel')
actual_ofx = [
x.get_attribute('outerHTML')
self.normalize_html(x.get_attribute('outerHTML'))
for x in ofxtrans_div.find_elements_by_class_name('reconcile-ofx')
]
expected_ofx = [
Expand Down Expand Up @@ -850,7 +850,7 @@ def test_07_edit(self, base_url, selenium):
# test that updated budget was removed from the page
trans_div = selenium.find_element_by_id('trans-panel')
actual_trans = [
t.get_attribute('outerHTML')
self.normalize_html(t.get_attribute('outerHTML'))
for t in trans_div.find_elements_by_class_name('reconcile-trans')
]
expected_trans = [
Expand Down Expand Up @@ -941,7 +941,7 @@ def test_06_success(self, base_url, selenium):
trans_id=3
)
)
assert tgt.get_attribute('outerHTML') == expected
assert self.normalize_html(tgt.get_attribute('outerHTML')) == expected
# ensure the reconciled variable was updated
assert self.get_reconciled(selenium) == {
3: [2, 'OFX3']
Expand Down Expand Up @@ -979,7 +979,7 @@ def test_07_already_has_ofx(self, base_url, selenium):
trans_id=5
)
)
assert tgt.get_attribute('outerHTML') == expected
assert self.normalize_html(tgt.get_attribute('outerHTML')) == expected
# ensure the reconciled variable was updated
assert self.get_reconciled(selenium) == {
5: [2, 'OFXT6']
Expand Down Expand Up @@ -1107,7 +1107,7 @@ def test_11_unreconcile(self, base_url, selenium):
trans_id=3
)
)
assert tgt.get_attribute('outerHTML') == expected
assert self.normalize_html(tgt.get_attribute('outerHTML')) == expected
# ensure the reconciled variable was updated
assert self.get_reconciled(selenium) == {
3: [2, 'OFX3']
Expand All @@ -1118,7 +1118,7 @@ def test_11_unreconcile(self, base_url, selenium):
src = selenium.find_element_by_id('ofx-2-OFX3')
tgt = selenium.find_element_by_id('trans-3')
assert src.is_displayed() is True
assert src.get_attribute('outerHTML') == ofx_div(
assert self.normalize_html(src.get_attribute('outerHTML')) == ofx_div(
date(2017, 4, 9),
600.00,
'BankTwo', 2,
Expand All @@ -1137,7 +1137,7 @@ def test_11_unreconcile(self, base_url, selenium):
'2Periodic', 2,
'trans2'
)
assert tgt.get_attribute('outerHTML') == expected
assert self.normalize_html(tgt.get_attribute('outerHTML')) == expected


@pytest.mark.acceptance
Expand Down Expand Up @@ -1612,7 +1612,7 @@ def test_08_trans_from_ofx(self, base_url, selenium):
# ensure that the Transaction was added, and the ofx moved to it
trans_div = selenium.find_element_by_id('trans-panel')
actual_trans = [
t.get_attribute('outerHTML')
self.normalize_html(t.get_attribute('outerHTML'))
for t in trans_div.find_elements_by_class_name('reconcile-trans')
]
expected_trans = [
Expand Down Expand Up @@ -1680,7 +1680,7 @@ def test_06_transactions_column(self, base_url, selenium):
self.get(selenium, base_url + '/reconcile')
trans_div = selenium.find_element_by_id('trans-panel')
actual_trans = [
x.get_attribute('outerHTML')
self.normalize_html(x.get_attribute('outerHTML'))
for x in trans_div.find_elements_by_class_name('reconcile-trans')
]
expected_trans = [
Expand Down Expand Up @@ -1739,7 +1739,7 @@ def test_07_ofx_column(self, base_url, selenium):
self.get(selenium, base_url + '/reconcile')
ofxtrans_div = selenium.find_element_by_id('ofx-panel')
actual_ofx = [
x.get_attribute('outerHTML')
self.normalize_html(x.get_attribute('outerHTML'))
for x in ofxtrans_div.find_elements_by_class_name('reconcile-ofx')
]
expected_ofx = [
Expand Down Expand Up @@ -1806,7 +1806,7 @@ def test_08_reconcile_unreconcile_noOFX_visible(self, base_url, selenium):
self.get(selenium, base_url + '/reconcile')
# check Trans and OFX
trans = selenium.find_element_by_id('trans-3')
assert trans.get_attribute('outerHTML') == txn_div(
assert self.normalize_html(trans.get_attribute('outerHTML')) == txn_div(
3,
date(2017, 4, 11),
600,
Expand All @@ -1815,7 +1815,7 @@ def test_08_reconcile_unreconcile_noOFX_visible(self, base_url, selenium):
'trans2'
)
ofx = selenium.find_element_by_id('ofx-2-OFX3')
assert ofx.get_attribute('outerHTML') == ofx_div(
assert self.normalize_html(ofx.get_attribute('outerHTML')) == ofx_div(
date(2017, 4, 9),
600.00,
'BankTwo', 2,
Expand All @@ -1837,7 +1837,7 @@ def test_08_reconcile_unreconcile_noOFX_visible(self, base_url, selenium):
}
# check Trans and OFX
trans = selenium.find_element_by_id('trans-3')
assert trans.get_attribute('outerHTML') == txn_div(
assert self.normalize_html(trans.get_attribute('outerHTML')) == txn_div(
3,
date(2017, 4, 11),
600,
Expand All @@ -1862,7 +1862,7 @@ def test_08_reconcile_unreconcile_noOFX_visible(self, base_url, selenium):
self.wait_for_jquery_done(selenium)
# check Trans and OFX
trans = selenium.find_element_by_id('trans-3')
assert trans.get_attribute('outerHTML') == txn_div(
assert self.normalize_html(trans.get_attribute('outerHTML')) == txn_div(
3,
date(2017, 4, 11),
600,
Expand All @@ -1871,7 +1871,7 @@ def test_08_reconcile_unreconcile_noOFX_visible(self, base_url, selenium):
'trans2'
)
ofx = selenium.find_element_by_id('ofx-2-OFX3')
assert ofx.get_attribute('outerHTML') == ofx_div(
assert self.normalize_html(ofx.get_attribute('outerHTML')) == ofx_div(
date(2017, 4, 9),
600.00,
'BankTwo', 2,
Expand All @@ -1895,7 +1895,7 @@ def test_09_reconcile_unreconcile_noOFX(self, base_url, selenium):
self.get(selenium, base_url + '/reconcile')
# check Trans and OFX
trans = selenium.find_element_by_id('trans-3')
assert trans.get_attribute('outerHTML') == txn_div(
assert self.normalize_html(trans.get_attribute('outerHTML')) == txn_div(
3,
date(2017, 4, 11),
600,
Expand All @@ -1904,7 +1904,7 @@ def test_09_reconcile_unreconcile_noOFX(self, base_url, selenium):
'trans2'
)
ofx = selenium.find_element_by_id('ofx-2-OFX3')
assert ofx.get_attribute('outerHTML') == ofx_div(
assert self.normalize_html(ofx.get_attribute('outerHTML')) == ofx_div(
date(2017, 4, 9),
600.00,
'BankTwo', 2,
Expand Down Expand Up @@ -1936,7 +1936,7 @@ def test_09_reconcile_unreconcile_noOFX(self, base_url, selenium):
'id="trans-3-noOFX" style=""><p><strong>No OFX:</strong>' \
' My Trans Note</p></div>'
trans = selenium.find_element_by_id('trans-3')
assert trans.get_attribute('outerHTML') == txn_div(
assert self.normalize_html(trans.get_attribute('outerHTML')) == txn_div(
3,
date(2017, 4, 11),
600,
Expand All @@ -1950,7 +1950,7 @@ def test_09_reconcile_unreconcile_noOFX(self, base_url, selenium):
# unreconcile
trans.find_element_by_link_text('Unreconcile').click()
trans = selenium.find_element_by_id('trans-3')
assert trans.get_attribute('outerHTML') == txn_div(
assert self.normalize_html(trans.get_attribute('outerHTML')) == txn_div(
3,
date(2017, 4, 11),
600,
Expand Down
14 changes: 14 additions & 0 deletions biweeklybudget/tests/acceptance_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@

class AcceptanceHelper(object):

def normalize_html(self, html):
"""
Given a HTML string, normalize some differences that may occur between
different test environments.
:param html: html
:type html: str
:return: normalized HTML
:rtype: str
"""
# strange inconsistency between local and TravisCI...
html = html.replace('style="display: none; "', 'style="display: none;"')
return html

def relurl(self, url):
"""
Given an absolute URL including ``self.baseurl``, return the relative
Expand Down

0 comments on commit 9a50ae9

Please sign in to comment.