@ -1,6 +1,9 @@
from django . core . urlresolvers import reverse
from django . test import TestCase
MovedPermanentlyHTTPStatusCode = 301
EMPTY_STRING = ' '
class RedirecionaURLsTests ( TestCase ) :
def test_redireciona_index_SAPL ( self ) :
@ -8,7 +11,7 @@ class RedirecionaURLsTests(TestCase):
' sapl.redireciona_urls:redireciona_sapl_index ' )
)
url_e = reverse ( ' sapl_index ' )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
@ -19,7 +22,7 @@ class RedirecionaParlamentarTests(TestCase):
url = reverse ( self . url_pattern )
url_e = reverse ( ' sapl.parlamentares:parlamentar_list ' )
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_parlamentar_list_por_legislatura ( self ) :
@ -36,7 +39,7 @@ class RedirecionaParlamentarTests(TestCase):
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_parlamentar_detail ( self ) :
@ -48,7 +51,7 @@ class RedirecionaParlamentarTests(TestCase):
kwargs = { ' pk ' : pk_parlamentar }
)
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
@ -64,7 +67,7 @@ class RedirecionaComissaoTests(TestCase):
kwargs = { ' pk ' : pk_comissao }
)
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_comissao_list ( self ) :
@ -72,7 +75,7 @@ class RedirecionaComissaoTests(TestCase):
url_e = reverse (
' sapl.comissoes:comissao_list ' )
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
@ -88,7 +91,7 @@ class RedirecionaPautaSessaoTests(TestCase):
kwargs = { ' pk ' : pk_pauta_sessao }
)
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_pauta_sessao_list ( self ) :
@ -97,7 +100,7 @@ class RedirecionaPautaSessaoTests(TestCase):
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_pauta_sessao_list_por_dat_sessao_sel ( self ) :
@ -113,7 +116,7 @@ class RedirecionaPautaSessaoTests(TestCase):
url_e = reverse ( ' sapl.sessao:pesquisar_pauta ' )
args_e = ' '
args_e = EMPTY_STRING
args_e + = " ?data_inicio__year= %s " % ( ano_s_p )
args_e + = " &data_inicio__month= %s " % ( mes_s_p . lstrip ( " 0 " ) )
args_e + = " &data_inicio__day= %s " % ( dia_s_p . lstrip ( " 0 " ) )
@ -123,7 +126,7 @@ class RedirecionaPautaSessaoTests(TestCase):
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
@ -136,7 +139,7 @@ class RedirecionaMesaDiretoraTests(TestCase):
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
@ -154,7 +157,7 @@ class RedirecionaMesaDiretoraParlamentarTests(TestCase):
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
@ -165,17 +168,17 @@ class RedirecionaNormasJuridicasListTests(TestCase):
url = reverse ( self . url_pattern )
url_e = reverse ( ' sapl.norma:norma_pesquisa ' )
tipo_norma = ' '
numero_norma = ' '
ano_norma = ' '
periodo_inicial_aprovacao = ' '
periodo_final_aprovacao = ' '
periodo_inicial_publicacao = ' '
periodo_final_publicacao = ' '
ementa_norma = ' '
assuntos_norma = ' '
args = ' '
tipo_norma = EMPTY_STRING
numero_norma = EMPTY_STRING
ano_norma = EMPTY_STRING
periodo_inicial_aprovacao = EMPTY_STRING
periodo_final_aprovacao = EMPTY_STRING
periodo_inicial_publicacao = EMPTY_STRING
periodo_final_publicacao = EMPTY_STRING
ementa_norma = EMPTY_STRING
assuntos_norma = EMPTY_STRING
args = EMPTY_STRING
args + = " ?lst_tip_norma= %s " % ( tipo_norma )
args + = " &txt_numero= %s " % ( numero_norma )
args + = " &txt_ano= %s " % ( ano_norma )
@ -188,7 +191,7 @@ class RedirecionaNormasJuridicasListTests(TestCase):
args + = " &salvar= %s " % ( ' Pesquisar ' )
url = " %s %s " % ( url , args )
args_e = ' '
args_e = EMPTY_STRING
args_e + = " ?tipo= %s " % ( tipo_norma )
args_e + = " &numero= %s " % ( numero_norma )
args_e + = " &ano= %s " % ( ano_norma )
@ -202,7 +205,7 @@ class RedirecionaNormasJuridicasListTests(TestCase):
url_e = " %s %s " % ( url_e , args_e )
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_norma_juridica_pesquisa_por_tipo ( self ) :
@ -210,16 +213,16 @@ class RedirecionaNormasJuridicasListTests(TestCase):
url_e = reverse ( ' sapl.norma:norma_pesquisa ' )
tipo_norma = ' 4 '
numero_norma = ' '
ano_norma = ' '
periodo_inicial_aprovacao = ' '
periodo_final_aprovacao = ' '
periodo_inicial_publicacao = ' '
periodo_final_publicacao = ' '
ementa_norma = ' '
assuntos_norma = ' '
args = ' '
numero_norma = EMPTY_STRING
ano_norma = EMPTY_STRING
periodo_inicial_aprovacao = EMPTY_STRING
periodo_final_aprovacao = EMPTY_STRING
periodo_inicial_publicacao = EMPTY_STRING
periodo_final_publicacao = EMPTY_STRING
ementa_norma = EMPTY_STRING
assuntos_norma = EMPTY_STRING
args = EMPTY_STRING
args + = " ?lst_tip_norma= %s " % ( tipo_norma )
args + = " &txt_numero= %s " % ( numero_norma )
args + = " &txt_ano= %s " % ( ano_norma )
@ -232,7 +235,7 @@ class RedirecionaNormasJuridicasListTests(TestCase):
args + = " &salvar= %s " % ( ' Pesquisar ' )
url = " %s %s " % ( url , args )
args_e = ' '
args_e = EMPTY_STRING
args_e + = " ?tipo= %s " % ( tipo_norma )
args_e + = " &numero= %s " % ( numero_norma )
args_e + = " &ano= %s " % ( ano_norma )
@ -246,24 +249,24 @@ class RedirecionaNormasJuridicasListTests(TestCase):
url_e = " %s %s " % ( url_e , args_e )
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_norma_juridica_pesquisa_por_ano ( self ) :
url = reverse ( self . url_pattern )
url_e = reverse ( ' sapl.norma:norma_pesquisa ' )
tipo_norma = ' '
numero_norma = ' '
tipo_norma = EMPTY_STRING
numero_norma = EMPTY_STRING
ano_norma = ' 2010 '
periodo_inicial_aprovacao = ' '
periodo_final_aprovacao = ' '
periodo_inicial_publicacao = ' '
periodo_final_publicacao = ' '
ementa_norma = ' '
assuntos_norma = ' '
args = ' '
periodo_inicial_aprovacao = EMPTY_STRING
periodo_final_aprovacao = EMPTY_STRING
periodo_inicial_publicacao = EMPTY_STRING
periodo_final_publicacao = EMPTY_STRING
ementa_norma = EMPTY_STRING
assuntos_norma = EMPTY_STRING
args = EMPTY_STRING
args + = " ?lst_tip_norma= %s " % ( tipo_norma )
args + = " &txt_numero= %s " % ( numero_norma )
args + = " &txt_ano= %s " % ( ano_norma )
@ -276,7 +279,7 @@ class RedirecionaNormasJuridicasListTests(TestCase):
args + = " &salvar= %s " % ( ' Pesquisar ' )
url = " %s %s " % ( url , args )
args_e = ' '
args_e = EMPTY_STRING
args_e + = " ?tipo= %s " % ( tipo_norma )
args_e + = " &numero= %s " % ( numero_norma )
args_e + = " &ano= %s " % ( ano_norma )
@ -290,7 +293,7 @@ class RedirecionaNormasJuridicasListTests(TestCase):
url_e = " %s %s " % ( url_e , args_e )
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
@ -302,7 +305,7 @@ class RedirecionaNormasJuridicasDetailTests(TestCase):
pk_norma = 120
args = ' '
args = EMPTY_STRING
args + = " ?cod_norma= %s " % ( pk_norma )
url = " %s %s " % ( url , args )
@ -313,22 +316,22 @@ class RedirecionaNormasJuridicasDetailTests(TestCase):
)
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_norma_juridica_detail_sem_parametros ( self ) :
url = reverse ( self . url_pattern )
pk_norma = ' '
pk_norma = EMPTY_STRING
args = ' '
args = EMPTY_STRING
args + = " ?cod_norma= %s " % ( pk_norma )
url = " %s %s " % ( url , args )
url_e = reverse ( ' sapl.norma:norma_pesquisa ' )
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
@ -346,19 +349,19 @@ class RedirecionaSessaoPlenariaTests(TestCase):
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_sessao_plenaria_list_sem_parametro ( self ) :
url = reverse ( self . url_pattern )
url_e = reverse ( ' sapl.sessao:pesquisar_sessao ' )
year = ' '
month = ' '
day = ' '
tipo_sessao = ' '
year = EMPTY_STRING
month = EMPTY_STRING
day = EMPTY_STRING
tipo_sessao = EMPTY_STRING
args = ' '
args = EMPTY_STRING
args + = " ?ano_sessao_sel= %s " % ( year )
args + = " &mes_sessao_sel= %s " % ( month )
args + = " &dia_sessao_sel= %s " % ( day )
@ -368,7 +371,7 @@ class RedirecionaSessaoPlenariaTests(TestCase):
# Remove zeros à esquerda
day = day . lstrip ( " 0 " )
month = month . lstrip ( " 0 " )
args_e = ' '
args_e = EMPTY_STRING
args_e + = " ?data_inicio__year= %s " % ( year )
args_e + = " &data_inicio__month= %s " % ( month )
args_e + = " &data_inicio__day= %s " % ( day )
@ -376,20 +379,19 @@ class RedirecionaSessaoPlenariaTests(TestCase):
url_e = " %s %s " % ( url_e , args_e )
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_sessao_plenaria_list_sem_tipo ( self ) :
# import ipdb; ipdb.set_trace()
url = reverse ( self . url_pattern )
url_e = reverse ( ' sapl.sessao:pesquisar_sessao ' )
year = ' 2015 '
month = ' 04 '
day = ' 06 '
tipo_sessao = ' '
tipo_sessao = EMPTY_STRING
args = ' '
args = EMPTY_STRING
args + = " ?ano_sessao_sel= %s " % ( year )
args + = " &mes_sessao_sel= %s " % ( month )
args + = " &dia_sessao_sel= %s " % ( day )
@ -399,7 +401,7 @@ class RedirecionaSessaoPlenariaTests(TestCase):
# Remove zeros à esquerda
day = day . lstrip ( " 0 " )
month = month . lstrip ( " 0 " )
args_e = ' '
args_e = EMPTY_STRING
args_e + = " ?data_inicio__year= %s " % ( year )
args_e + = " &data_inicio__month= %s " % ( month )
args_e + = " &data_inicio__day= %s " % ( day )
@ -407,20 +409,19 @@ class RedirecionaSessaoPlenariaTests(TestCase):
url_e = " %s %s " % ( url_e , args_e )
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_sessao_plenaria_list_sem_tipo_e_ano ( self ) :
# import ipdb; ipdb.set_trace()
url = reverse ( self . url_pattern )
url_e = reverse ( ' sapl.sessao:pesquisar_sessao ' )
year = ' '
year = EMPTY_STRING
month = ' 04 '
day = ' 06 '
tipo_sessao = ' '
tipo_sessao = EMPTY_STRING
args = ' '
args = EMPTY_STRING
args + = " ?ano_sessao_sel= %s " % ( year )
args + = " &mes_sessao_sel= %s " % ( month )
args + = " &dia_sessao_sel= %s " % ( day )
@ -430,7 +431,7 @@ class RedirecionaSessaoPlenariaTests(TestCase):
# Remove zeros à esquerda
day = day . lstrip ( " 0 " )
month = month . lstrip ( " 0 " )
args_e = ' '
args_e = EMPTY_STRING
args_e + = " ?data_inicio__year= %s " % ( year )
args_e + = " &data_inicio__month= %s " % ( month )
args_e + = " &data_inicio__day= %s " % ( day )
@ -438,20 +439,19 @@ class RedirecionaSessaoPlenariaTests(TestCase):
url_e = " %s %s " % ( url_e , args_e )
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_sessao_plenaria_list_sem_ano ( self ) :
# import ipdb; ipdb.set_trace()
url = reverse ( self . url_pattern )
url_e = reverse ( ' sapl.sessao:pesquisar_sessao ' )
year = ' '
year = EMPTY_STRING
month = ' 04 '
day = ' 06 '
tipo_sessao = ' 4 '
args = ' '
args = EMPTY_STRING
args + = " ?ano_sessao_sel= %s " % ( year )
args + = " &mes_sessao_sel= %s " % ( month )
args + = " &dia_sessao_sel= %s " % ( day )
@ -461,27 +461,26 @@ class RedirecionaSessaoPlenariaTests(TestCase):
# Remove zeros à esquerda
day = day . lstrip ( " 0 " )
month = month . lstrip ( " 0 " )
args_e = ' '
args_e = EMPTY_STRING
args_e + = " ?data_inicio__year= %s " % ( year )
args_e + = " &data_inicio__month= %s " % ( month )
args_e + = " &data_inicio__day= %s " % ( day )
args_e + = " &tipo= %s &salvar=Pesquisar " % ( tipo_sessao )
url_e = " %s %s " % ( url_e , args_e )
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_sessao_plenaria_list_sem_mes_dia ( self ) :
# import ipdb; ipdb.set_trace()
url = reverse ( self . url_pattern )
url_e = reverse ( ' sapl.sessao:pesquisar_sessao ' )
year = ' 2015 '
month = ' '
day = ' '
month = EMPTY_STRING
day = EMPTY_STRING
tipo_sessao = ' 4 '
args = ' '
args = EMPTY_STRING
args + = " ?ano_sessao_sel= %s " % ( year )
args + = " &mes_sessao_sel= %s " % ( month )
args + = " &dia_sessao_sel= %s " % ( day )
@ -491,12 +490,114 @@ class RedirecionaSessaoPlenariaTests(TestCase):
# Remove zeros à esquerda
day = day . lstrip ( " 0 " )
month = month . lstrip ( " 0 " )
args_e = ' '
args_e = EMPTY_STRING
args_e + = " ?data_inicio__year= %s " % ( year )
args_e + = " &data_inicio__month= %s " % ( month )
args_e + = " &data_inicio__day= %s " % ( day )
args_e + = " &tipo= %s &salvar=Pesquisar " % ( tipo_sessao )
url_e = " %s %s " % ( url_e , args_e )
response = self . client . get ( url )
self . assertEqual ( response . status_code , 301 )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
class RedirecionaHistoricoTramitacoesListTests ( TestCase ) :
url_pattern = ' sapl.redireciona_urls:redireciona_historico_tramitacoes '
def test_redireciona_historico_tramitacoes_sem_parametros ( self ) :
args_e = EMPTY_STRING
args = EMPTY_STRING
url = reverse ( self . url_pattern )
url_e = reverse ( ' sapl.base:historico_tramitacoes ' )
inicio_intervalo_data_tramitacao = EMPTY_STRING
fim_intervalo_data_tramitacao = EMPTY_STRING
tipo_materia = EMPTY_STRING
unidade_local_tramitacao = EMPTY_STRING
status_tramitacao = EMPTY_STRING
args + = " ?txt_dat_inicio_periodo= %s " % ( inicio_intervalo_data_tramitacao )
args + = " &txt_dat_fim_periodo= %s " % ( fim_intervalo_data_tramitacao )
args + = " &lst_tip_materia= %s " % ( tipo_materia )
args + = " &lst_cod_unid_tram_dest= %s " % ( unidade_local_tramitacao )
args + = " &lst_status= %s " % ( status_tramitacao )
args + = " &btn_materia_pesquisar= %s " % ( ' Pesquisar ' )
url = " %s %s " % ( url , args )
# Remove zeros à esquerda
inicio_intervalo_data_tramitacao = inicio_intervalo_data_tramitacao . lstrip ( " 0 " )
fim_intervalo_data_tramitacao = fim_intervalo_data_tramitacao . lstrip ( " 0 " )
tipo_materia = tipo_materia . lstrip ( " 0 " )
unidade_local_tramitacao = unidade_local_tramitacao . lstrip ( " 0 " )
status_tramitacao = status_tramitacao . lstrip ( " 0 " )
if ( ( inicio_intervalo_data_tramitacao != EMPTY_STRING ) or
( fim_intervalo_data_tramitacao != EMPTY_STRING ) or
( tipo_materia != EMPTY_STRING ) or
( unidade_local_tramitacao != EMPTY_STRING ) or
( status_tramitacao != EMPTY_STRING )
) :
args_e + = " ?tramitacao__data_tramitacao_0= %s " % (
inicio_intervalo_data_tramitacao )
args_e + = " &tramitacao__data_tramitacao_1= %s " % (
fim_intervalo_data_tramitacao )
args_e + = " &tipo= %s " % ( tipo_materia )
args_e + = " &tramitacao__unidade_tramitacao_local= %s " % (
unidade_local_tramitacao )
args_e + = " &tramitacao__status= %s " % ( status_tramitacao )
args_e + = " &salvar= %s " % ( ' Pesquisar ' )
url_e = " %s %s " % ( url_e , args_e )
response = self . client . get ( url )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )
def test_redireciona_historico_tramitacoes ( self ) :
args = EMPTY_STRING
args_e = EMPTY_STRING
url = reverse ( self . url_pattern )
url_e = reverse ( ' sapl.base:historico_tramitacoes ' )
inicio_intervalo_data_tramitacao = ' 12/07/2000 '
fim_intervalo_data_tramitacao = ' 26/05/2017 '
unidade_local_tramitacao = ' 0 '
tipo_materia = ' 0 '
status_tramitacao = ' 0 '
args + = " ?txt_dat_inicio_periodo= %s " % ( inicio_intervalo_data_tramitacao )
args + = " &txt_dat_fim_periodo= %s " % ( fim_intervalo_data_tramitacao )
args + = " &lst_tip_materia= %s " % ( tipo_materia )
args + = " &lst_cod_unid_tram_dest= %s " % ( unidade_local_tramitacao )
args + = " &lst_status= %s " % ( status_tramitacao )
args + = " &btn_materia_pesquisar= %s " % ( ' Pesquisar ' )
url = " %s %s " % ( url , args )
# Remove zeros à esquerda
inicio_intervalo_data_tramitacao = inicio_intervalo_data_tramitacao . lstrip ( " 0 " )
fim_intervalo_data_tramitacao = fim_intervalo_data_tramitacao . lstrip ( " 0 " )
tipo_materia = tipo_materia . lstrip ( " 0 " )
unidade_local_tramitacao = unidade_local_tramitacao . lstrip ( " 0 " )
status_tramitacao = status_tramitacao . lstrip ( " 0 " )
if ( ( inicio_intervalo_data_tramitacao != EMPTY_STRING ) or
( fim_intervalo_data_tramitacao != EMPTY_STRING ) or
( tipo_materia != EMPTY_STRING ) or
( unidade_local_tramitacao != EMPTY_STRING ) or
( status_tramitacao != EMPTY_STRING )
) :
args_e + = " ?tramitacao__data_tramitacao_0= %s " % (
inicio_intervalo_data_tramitacao )
args_e + = " &tramitacao__data_tramitacao_1= %s " % (
fim_intervalo_data_tramitacao )
args_e + = " &tipo= %s " % ( tipo_materia )
args_e + = " &tramitacao__unidade_tramitacao_local= %s " % (
unidade_local_tramitacao )
args_e + = " &tramitacao__status= %s " % ( status_tramitacao )
args_e + = " &salvar= %s " % ( ' Pesquisar ' )
url_e = " %s %s " % ( url_e , args_e )
response = self . client . get ( url )
self . assertEqual ( response . status_code , MovedPermanentlyHTTPStatusCode )
self . assertEqual ( response . url , url_e )