Browse Source

Fix #281

pull/326/head
Edward Ribeiro 9 years ago
parent
commit
c6a1453b13
  1. 5
      comissoes/tests/test_comissoes.py
  2. 44
      materia/tests/test_email_templates.py
  3. 11
      materia/tests/test_materia.py
  4. 0
      materia/tests/test_materia_urls.py
  5. 2
      norma/tests/test_norma.py
  6. 0
      painel/tests/tests.py
  7. 2
      parlamentares/tests/test_mandato.py
  8. 4
      parlamentares/tests/test_parlamentares.py
  9. 4
      protocoloadm/tests/test_protocoloadm.py

5
comissoes/test_comissoes.py → comissoes/tests/test_comissoes.py

@ -2,11 +2,10 @@ import pytest
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from model_mommy import mommy from model_mommy import mommy
from comissoes.models import (CargoComissao, Comissao, Composicao,
Participacao, Periodo, TipoComissao)
from parlamentares.models import Filiacao, Parlamentar, Partido from parlamentares.models import Filiacao, Parlamentar, Partido
from .models import (CargoComissao, Comissao, Composicao, Participacao,
Periodo, TipoComissao)
def make_composicao(comissao): def make_composicao(comissao):
periodo = mommy.make(Periodo, periodo = mommy.make(Periodo,

44
templates/materia/test_email_templates.py → materia/tests/test_email_templates.py

@ -1,15 +1,12 @@
import pytest
from base.models import CasaLegislativa
from django.core import mail from django.core import mail
from model_mommy import mommy
from materia.views import load_email_templates, enviar_emails, criar_email_tramitacao from materia.views import enviar_emails, load_email_templates
from materia.models import MateriaLegislativa, TipoMateriaLegislativa
def test_email_template_loading(): def test_email_template_loading():
expected = "<html><body>Hello Django</body></html>" expected = "<html><body>Hello Django</body></html>"
emails = load_email_templates(['email/test_tramitacao.html'], emails = load_email_templates(['email/test_tramitacao.html'],
context={"name": "Django"}) context={"name": "Django"})
# strip \n and \r to compare with expected # strip \n and \r to compare with expected
actual = emails[0].replace('\n', '').replace('\r', '') actual = emails[0].replace('\n', '').replace('\r', '')
@ -20,20 +17,23 @@ def test_email_template_loading():
def test_html_email_body_with_materia(): def test_html_email_body_with_materia():
templates = load_email_templates(['email/tramitacao.txt', templates = load_email_templates(['email/tramitacao.txt',
'email/tramitacao.html'], 'email/tramitacao.html'],
{"image":'img/logo.png', {"image": 'img/logo.png',
"casa_legislativa":"Assembléia Parlamentar", "casa_legislativa":
"data_registro":"25/02/2016", "Assembléia Parlamentar",
"cod_materia":"1", "data_registro": "25/02/2016",
"descricao_materia":"Ementa de teste", "cod_materia": "1",
"autoria": ["Autor1", "Autor2"], "descricao_materia": "Ementa de teste",
"data":"25/02/2016", "autoria": ["Autor1", "Autor2"],
"status":"Arquivado", "data": "25/02/2016",
"texto_acao":"Deliberado", "status": "Arquivado",
"hash_txt":"abc01f", "texto_acao": "Deliberado",
"materia_id": "794", "hash_txt": "abc01f",
"base_url": "http://localhost:8000", "materia_id": "794",
"materia_url": "/materia/764/acompanhar-materia", "base_url": "http://localhost:8000",
"excluir_url": "/materia/764/acompanhar-excluir",}) "materia_url":
"/materia/764/acompanhar-materia",
"excluir_url":
"/materia/764/acompanhar-excluir"})
assert len(templates) == 2 assert len(templates) == 2
@ -44,7 +44,7 @@ def test_enviar_email_distintos():
'subject': 'subject: ' + str(i), 'subject': 'subject: ' + str(i),
'txt_message': 'txt: ' + str(i), 'txt_message': 'txt: ' + str(i),
'html_message': '<html></html>', 'html_message': '<html></html>',
} for i in range(NUM_MESSAGES)] } for i in range(NUM_MESSAGES)]
recipients = [m['recipient'] for m in messages] recipients = [m['recipient'] for m in messages]
@ -58,7 +58,7 @@ def test_enviar_same_email():
'subject': 'subject: ' + str(i), 'subject': 'subject: ' + str(i),
'txt_message': 'txt: ' + str(i), 'txt_message': 'txt: ' + str(i),
'html_message': '<html></html>', 'html_message': '<html></html>',
} for i in range(NUM_MESSAGES)] } for i in range(NUM_MESSAGES)]
recipients = [m['recipient'] for m in messages] recipients = [m['recipient'] for m in messages]

11
materia/test_materia.py → materia/tests/test_materia.py

@ -3,14 +3,13 @@ from django.core.urlresolvers import reverse
from model_mommy import mommy from model_mommy import mommy
from comissoes.models import Comissao, TipoComissao 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 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): def make_unidade_tramitacao(descricao):
# Cria uma comissão para ser a unidade de tramitação # Cria uma comissão para ser a unidade de tramitação

0
materia/test_materia_urls.py → materia/tests/test_materia_urls.py

2
norma/test_norma.py → norma/tests/test_norma.py

@ -2,7 +2,7 @@ import pytest
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from model_mommy import mommy from model_mommy import mommy
from .models import NormaJuridica, TipoNormaJuridica from norma.models import NormaJuridica, TipoNormaJuridica
@pytest.mark.django_db(transaction=False) @pytest.mark.django_db(transaction=False)

0
painel/tests.py → painel/tests/tests.py

2
parlamentares/test_mandato.py → parlamentares/tests/test_mandato.py

@ -3,7 +3,7 @@ from datetime import datetime
import pytest import pytest
from model_mommy import mommy from model_mommy import mommy
from .models import Filiacao, Legislatura, Mandato from parlamentares.models import Filiacao, Legislatura, Mandato
pytestmark = pytest.mark.django_db pytestmark = pytest.mark.django_db

4
parlamentares/test_parlamentares.py → parlamentares/tests/test_parlamentares.py

@ -2,8 +2,8 @@ import pytest
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from model_mommy import mommy from model_mommy import mommy
from .models import (Dependente, Filiacao, Legislatura, Mandato, Parlamentar, from parlamentares.models import (Dependente, Filiacao, Legislatura, Mandato,
Partido, TipoDependente) Parlamentar, Partido, TipoDependente)
@pytest.mark.django_db(transaction=False) @pytest.mark.django_db(transaction=False)

4
protocoloadm/test_protocoloadm.py → protocoloadm/tests/test_protocoloadm.py

@ -3,8 +3,8 @@ from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from model_mommy import mommy from model_mommy import mommy
from .forms import AnularProcoloAdmForm from protocoloadm.forms import AnularProcoloAdmForm
from .models import Protocolo from protocoloadm.models import Protocolo
@pytest.mark.django_db(transaction=False) @pytest.mark.django_db(transaction=False)
Loading…
Cancel
Save