From 09aa99f4daa87cec0b6f9183d0827d07b93b90c9 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Tue, 26 Apr 2016 11:09:21 -0300 Subject: [PATCH] Fix tests --- parlamentares/forms.py | 6 ++++-- parlamentares/tests/test_parlamentares.py | 4 ++-- protocoloadm/views.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/parlamentares/forms.py b/parlamentares/forms.py index 5993b0ae1..ead139e7b 100644 --- a/parlamentares/forms.py +++ b/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, diff --git a/parlamentares/tests/test_parlamentares.py b/parlamentares/tests/test_parlamentares.py index 9744aee38..969af9de6 100644 --- a/parlamentares/tests/test_parlamentares.py +++ b/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'}, diff --git a/protocoloadm/views.py b/protocoloadm/views.py index 14cec4ea3..8757debd4 100644 --- a/protocoloadm/views.py +++ b/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 _