Browse Source

Refactor test to use WebTest app

producao
Marcio Mazza 10 years ago
parent
commit
b021cb198e
  1. 26
      sigi/apps/utils/test_base_admin.py

26
sigi/apps/utils/test_base_admin.py

@ -1,15 +1,23 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
def test_clear_all_filters_is_disabled_if_no_filter_was_used(admin_client): def get_li_clear_all_filters(res):
response = admin_client.get('/parlamentares/parlamentar', follow=True) text = res.html.find(text='Clear All Filters')
assert response.status_code == 200 li = text.find_parent('li')
assert '<li class="clear-all-filter disabled"><a href="?">Clear All Filters</a></li>' in response.content assert li
return li
def test_clear_all_filters_is_enabled_if_some_filter_was_used(admin_client): def test_clear_all_filters_is_disabled_if_no_filter_was_used(app):
res = app.get('/parlamentares/parlamentar/')
assert res.status_code == 200
li = get_li_clear_all_filters(res)
assert 'disabled' in li.attrs['class']
def test_clear_all_filters_is_enabled_if_some_filter_was_used(app):
# now we filter by capital letter # now we filter by capital letter
response = admin_client.get('/parlamentares/parlamentar/?nome_completo=B', follow=True) res = app.get('/parlamentares/parlamentar/?nome_completo=B')
assert response.status_code == 200 assert res.status_code == 200
# and there is no "disabled" css class li = get_li_clear_all_filters(res)
assert '<li class="clear-all-filter"><a href="?">Clear All Filters</a></li>' in response.content assert 'disabled' not in li.attrs['class']

Loading…
Cancel
Save