From c6a1453b131fc61dd2d0f8bd53995be1d46b5377 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Tue, 19 Apr 2016 11:00:22 -0300 Subject: [PATCH] Fix #281 --- comissoes/{ => tests}/test_comissoes.py | 5 +-- .../tests}/test_email_templates.py | 44 +++++++++---------- materia/{ => tests}/test_materia.py | 11 +++-- materia/{ => tests}/test_materia_urls.py | 0 norma/{ => tests}/test_norma.py | 2 +- painel/{ => tests}/tests.py | 0 parlamentares/{ => tests}/test_mandato.py | 2 +- .../{ => tests}/test_parlamentares.py | 4 +- protocoloadm/{ => tests}/test_protocoloadm.py | 4 +- 9 files changed, 35 insertions(+), 37 deletions(-) rename comissoes/{ => tests}/test_comissoes.py (97%) rename {templates/materia => materia/tests}/test_email_templates.py (50%) rename materia/{ => tests}/test_materia.py (97%) rename materia/{ => tests}/test_materia_urls.py (100%) rename norma/{ => tests}/test_norma.py (96%) rename painel/{ => tests}/tests.py (100%) rename parlamentares/{ => tests}/test_mandato.py (94%) rename parlamentares/{ => tests}/test_parlamentares.py (97%) rename protocoloadm/{ => tests}/test_protocoloadm.py (97%) diff --git a/comissoes/test_comissoes.py b/comissoes/tests/test_comissoes.py similarity index 97% rename from comissoes/test_comissoes.py rename to comissoes/tests/test_comissoes.py index 665146d35..5c76c342d 100644 --- a/comissoes/test_comissoes.py +++ b/comissoes/tests/test_comissoes.py @@ -2,11 +2,10 @@ import pytest from django.core.urlresolvers import reverse from model_mommy import mommy +from comissoes.models import (CargoComissao, Comissao, Composicao, + Participacao, Periodo, TipoComissao) from parlamentares.models import Filiacao, Parlamentar, Partido -from .models import (CargoComissao, Comissao, Composicao, Participacao, - Periodo, TipoComissao) - def make_composicao(comissao): periodo = mommy.make(Periodo, diff --git a/templates/materia/test_email_templates.py b/materia/tests/test_email_templates.py similarity index 50% rename from templates/materia/test_email_templates.py rename to materia/tests/test_email_templates.py index ad4d9a6ec..943c12a0a 100644 --- a/templates/materia/test_email_templates.py +++ b/materia/tests/test_email_templates.py @@ -1,15 +1,12 @@ -import pytest -from base.models import CasaLegislativa from django.core import mail -from model_mommy import mommy -from materia.views import load_email_templates, enviar_emails, criar_email_tramitacao -from materia.models import MateriaLegislativa, TipoMateriaLegislativa + +from materia.views import enviar_emails, load_email_templates def test_email_template_loading(): expected = "Hello Django" emails = load_email_templates(['email/test_tramitacao.html'], - context={"name": "Django"}) + context={"name": "Django"}) # strip \n and \r to compare with expected actual = emails[0].replace('\n', '').replace('\r', '') @@ -20,20 +17,23 @@ def test_email_template_loading(): def test_html_email_body_with_materia(): templates = load_email_templates(['email/tramitacao.txt', 'email/tramitacao.html'], - {"image":'img/logo.png', - "casa_legislativa":"Assembléia Parlamentar", - "data_registro":"25/02/2016", - "cod_materia":"1", - "descricao_materia":"Ementa de teste", - "autoria": ["Autor1", "Autor2"], - "data":"25/02/2016", - "status":"Arquivado", - "texto_acao":"Deliberado", - "hash_txt":"abc01f", - "materia_id": "794", - "base_url": "http://localhost:8000", - "materia_url": "/materia/764/acompanhar-materia", - "excluir_url": "/materia/764/acompanhar-excluir",}) + {"image": 'img/logo.png', + "casa_legislativa": + "Assembléia Parlamentar", + "data_registro": "25/02/2016", + "cod_materia": "1", + "descricao_materia": "Ementa de teste", + "autoria": ["Autor1", "Autor2"], + "data": "25/02/2016", + "status": "Arquivado", + "texto_acao": "Deliberado", + "hash_txt": "abc01f", + "materia_id": "794", + "base_url": "http://localhost:8000", + "materia_url": + "/materia/764/acompanhar-materia", + "excluir_url": + "/materia/764/acompanhar-excluir"}) assert len(templates) == 2 @@ -44,7 +44,7 @@ def test_enviar_email_distintos(): 'subject': 'subject: ' + str(i), 'txt_message': 'txt: ' + str(i), 'html_message': '', - } for i in range(NUM_MESSAGES)] + } for i in range(NUM_MESSAGES)] recipients = [m['recipient'] for m in messages] @@ -58,7 +58,7 @@ def test_enviar_same_email(): 'subject': 'subject: ' + str(i), 'txt_message': 'txt: ' + str(i), 'html_message': '', - } for i in range(NUM_MESSAGES)] + } for i in range(NUM_MESSAGES)] recipients = [m['recipient'] for m in messages] diff --git a/materia/test_materia.py b/materia/tests/test_materia.py similarity index 97% rename from materia/test_materia.py rename to materia/tests/test_materia.py index 04fdfddb4..71d7ccb05 100644 --- a/materia/test_materia.py +++ b/materia/tests/test_materia.py @@ -3,14 +3,13 @@ from django.core.urlresolvers import reverse from model_mommy import mommy from comissoes.models import Comissao, TipoComissao +from materia.models import (Anexada, Autor, Autoria, DespachoInicial, + DocumentoAcessorio, MateriaLegislativa, Numeracao, + Proposicao, RegimeTramitacao, StatusTramitacao, + TipoAutor, TipoDocumento, TipoMateriaLegislativa, + TipoProposicao, Tramitacao, UnidadeTramitacao) from norma.models import LegislacaoCitada, NormaJuridica, TipoNormaJuridica -from .models import (Anexada, Autor, Autoria, DespachoInicial, - DocumentoAcessorio, MateriaLegislativa, Numeracao, - Proposicao, RegimeTramitacao, StatusTramitacao, TipoAutor, - TipoDocumento, TipoMateriaLegislativa, TipoProposicao, - Tramitacao, UnidadeTramitacao) - def make_unidade_tramitacao(descricao): # Cria uma comissão para ser a unidade de tramitação diff --git a/materia/test_materia_urls.py b/materia/tests/test_materia_urls.py similarity index 100% rename from materia/test_materia_urls.py rename to materia/tests/test_materia_urls.py diff --git a/norma/test_norma.py b/norma/tests/test_norma.py similarity index 96% rename from norma/test_norma.py rename to norma/tests/test_norma.py index e25b3dbfd..b510aa566 100644 --- a/norma/test_norma.py +++ b/norma/tests/test_norma.py @@ -2,7 +2,7 @@ import pytest from django.core.urlresolvers import reverse from model_mommy import mommy -from .models import NormaJuridica, TipoNormaJuridica +from norma.models import NormaJuridica, TipoNormaJuridica @pytest.mark.django_db(transaction=False) diff --git a/painel/tests.py b/painel/tests/tests.py similarity index 100% rename from painel/tests.py rename to painel/tests/tests.py diff --git a/parlamentares/test_mandato.py b/parlamentares/tests/test_mandato.py similarity index 94% rename from parlamentares/test_mandato.py rename to parlamentares/tests/test_mandato.py index ce855450d..0e4ece06f 100644 --- a/parlamentares/test_mandato.py +++ b/parlamentares/tests/test_mandato.py @@ -3,7 +3,7 @@ from datetime import datetime import pytest from model_mommy import mommy -from .models import Filiacao, Legislatura, Mandato +from parlamentares.models import Filiacao, Legislatura, Mandato pytestmark = pytest.mark.django_db diff --git a/parlamentares/test_parlamentares.py b/parlamentares/tests/test_parlamentares.py similarity index 97% rename from parlamentares/test_parlamentares.py rename to parlamentares/tests/test_parlamentares.py index 81d9b35ed..becb11753 100644 --- a/parlamentares/test_parlamentares.py +++ b/parlamentares/tests/test_parlamentares.py @@ -2,8 +2,8 @@ import pytest from django.core.urlresolvers import reverse from model_mommy import mommy -from .models import (Dependente, Filiacao, Legislatura, Mandato, Parlamentar, - Partido, TipoDependente) +from parlamentares.models import (Dependente, Filiacao, Legislatura, Mandato, + Parlamentar, Partido, TipoDependente) @pytest.mark.django_db(transaction=False) diff --git a/protocoloadm/test_protocoloadm.py b/protocoloadm/tests/test_protocoloadm.py similarity index 97% rename from protocoloadm/test_protocoloadm.py rename to protocoloadm/tests/test_protocoloadm.py index 7df53f91a..811950610 100644 --- a/protocoloadm/test_protocoloadm.py +++ b/protocoloadm/tests/test_protocoloadm.py @@ -3,8 +3,8 @@ from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from model_mommy import mommy -from .forms import AnularProcoloAdmForm -from .models import Protocolo +from protocoloadm.forms import AnularProcoloAdmForm +from protocoloadm.models import Protocolo @pytest.mark.django_db(transaction=False)