Browse Source

Fix tests

pull/341/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
committed by Edward Ribeiro
parent
commit
09aa99f4da
  1. 6
      parlamentares/forms.py
  2. 4
      parlamentares/tests/test_parlamentares.py
  3. 2
      protocoloadm/views.py

6
parlamentares/forms.py

@ -104,7 +104,7 @@ def validate(data, data_desfiliacao, parlamentar, filiacao):
break
if error_msg:
raise forms.ValidationError(error_msg)
return [False, error_msg]
return [True, '']
@ -118,8 +118,10 @@ class FiliacaoForm(ModelForm):
'data_desfiliacao']
def clean(self):
filiacao = super(FiliacaoForm, self).save(commit=False)
if self.errors:
return self.errors
filiacao = super(FiliacaoForm, self).save(commit=False)
validacao = validate(self.cleaned_data['data'],
self.cleaned_data['data_desfiliacao'],
filiacao.parlamentar,

4
parlamentares/tests/test_parlamentares.py

@ -53,7 +53,7 @@ def test_filiacao_submit(client):
mommy.make(Parlamentar, pk=14)
mommy.make(Partido, pk=32)
client.post(reverse('parlamentares:parlamentar_filiacao',
client.post(reverse('parlamentares:filiacao_create',
kwargs={'pk': 14}),
{'partido': 32,
'data': '2016-03-22',
@ -103,7 +103,7 @@ def test_form_errors_dependente(client):
def test_form_errors_filiacao(client):
mommy.make(Parlamentar, pk=14)
response = client.post(reverse('parlamentares:parlamentar_filiacao',
response = client.post(reverse('parlamentares:filiacao_create',
kwargs={'pk': 14}),
{'partido': '',
'salvar': 'salvar'},

2
protocoloadm/views.py

@ -3,7 +3,7 @@ from datetime import date, datetime
from braces.views import FormValidMessageMixin
from django.core.urlresolvers import reverse, reverse_lazy
from django.db.models import Max, Q
from django.db.models import Q, Max
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _

Loading…
Cancel
Save