From 247fb3378456dc7979162ed3dcf1cf14f4a58d8c Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Fri, 10 Oct 2014 17:56:51 -0300 Subject: [PATCH] Add parlamentarian list test --- sigi/apps/parlamentares/test_parlamentares.py | 36 +++++++++++++++++++ sigi/settings/test.py | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 sigi/apps/parlamentares/test_parlamentares.py diff --git a/sigi/apps/parlamentares/test_parlamentares.py b/sigi/apps/parlamentares/test_parlamentares.py new file mode 100644 index 0000000..9f66389 --- /dev/null +++ b/sigi/apps/parlamentares/test_parlamentares.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +import pytest +from django_dynamic_fixture import G + +from sigi.apps.parlamentares.models import Parlamentar + + +pytestmark = pytest.mark.django_db + + +@pytest.fixture +def some_parlamentarians(): + a = G(Parlamentar, nome_completo=u"Andre Silva", foto=None) + b = G(Parlamentar, nome_completo=u"Bartolomeu Gusmao", foto=None) + c = G(Parlamentar, nome_completo=u"Camila Carla", foto=None) + return a, b, c + + +def test_list(some_parlamentarians, admin_client): + response = admin_client.get('/parlamentares/parlamentar', follow=True) + assert response.status_code == 200 + + decoded_content = response.content.decode('utf-8') + for x in some_parlamentarians: + assert x.nome_completo in decoded_content + + +def test_list_filtered_by_capital_letter(some_parlamentarians, admin_client): + response = admin_client.get('/parlamentares/parlamentar/?nome_completo=B', follow=True) + assert response.status_code == 200 + + decoded_content = response.content.decode('utf-8') + a, b, c = some_parlamentarians + assert a.nome_completo not in decoded_content + assert b.nome_completo in decoded_content + assert c.nome_completo not in decoded_content diff --git a/sigi/settings/test.py b/sigi/settings/test.py index b742c3a..b6c7dec 100644 --- a/sigi/settings/test.py +++ b/sigi/settings/test.py @@ -7,7 +7,7 @@ SECRET_KEY = '0$ip1fb5xtq%a=)-k_4r^(#jn0t^@+*^kihkxkozg-mip7+w3+' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'sigi_test', + 'NAME': 'sigi', # will be actually used as "test_sigi" by pytest-django 'USER': 'sigi', 'PASSWORD': 'sigi', 'HOST': 'localhost',