From b021cb198ee975508acea46ace4177882bcc8f42 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Fri, 7 Nov 2014 15:25:33 -0200 Subject: [PATCH] Refactor test to use WebTest app --- sigi/apps/utils/test_base_admin.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/sigi/apps/utils/test_base_admin.py b/sigi/apps/utils/test_base_admin.py index ff3268d..2f2f96e 100644 --- a/sigi/apps/utils/test_base_admin.py +++ b/sigi/apps/utils/test_base_admin.py @@ -1,15 +1,23 @@ # -*- coding: utf-8 -*- -def test_clear_all_filters_is_disabled_if_no_filter_was_used(admin_client): - response = admin_client.get('/parlamentares/parlamentar', follow=True) - assert response.status_code == 200 - assert '
  • Clear All Filters
  • ' in response.content +def get_li_clear_all_filters(res): + text = res.html.find(text='Clear All Filters') + li = text.find_parent('li') + 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 - response = admin_client.get('/parlamentares/parlamentar/?nome_completo=B', follow=True) - assert response.status_code == 200 - # and there is no "disabled" css class - assert '
  • Clear All Filters
  • ' in response.content + res = app.get('/parlamentares/parlamentar/?nome_completo=B') + assert res.status_code == 200 + li = get_li_clear_all_filters(res) + assert 'disabled' not in li.attrs['class']