Exemplo n.º 1
0
def test_elegir_acta_mesas_redirige(db, fiscal_client):

    assert Mesa.objects.count() == 0
    assert VotoMesaReportado.objects.count() == 0
    c = CircuitoFactory()
    e1 = EleccionFactory()
    e2 = EleccionFactory()

    m1 = AttachmentFactory(mesa__eleccion=[e1],
                           mesa__lugar_votacion__circuito=c).mesa
    e2 = EleccionFactory()
    m2 = AttachmentFactory(mesa__eleccion=[e1, e2],
                           mesa__lugar_votacion__circuito=c).mesa

    assert m1.orden_de_carga == 1
    assert m2.orden_de_carga == 2

    response = fiscal_client.get(reverse('elegir-acta-a-cargar'))
    assert response.status_code == 302
    assert response.url == reverse('mesa-cargar-resultados',
                                   args=[e1.id, m1.numero])

    # como m1 queda en periodo de "taken" (aunque no se haya ocupado aun)
    # se pasa a la siguiente mesa
    response = fiscal_client.get(reverse('elegir-acta-a-cargar'))
    assert response.status_code == 302
    assert response.url == reverse('mesa-cargar-resultados',
                                   args=[e1.id, m2.numero])

    # se carga esa eleccion
    VotoMesaReportadoFactory(mesa=m2,
                             eleccion=e1,
                             opcion=e1.opciones.first(),
                             votos=1)

    # FIX ME . El periodo de taken deberia ser *por eleccion*.
    # en este escenario donde esta lockeado la mesa para la eleccion 1, pero no se está
    # cargando la mesa 2, un dataentry queda idle
    response = fiscal_client.get(reverse('elegir-acta-a-cargar'))
    assert response.status_code == 200  # no hay actas

    m2.taken = None
    m2.save()
    response = fiscal_client.get(reverse('elegir-acta-a-cargar'))
    assert response.status_code == 302
    assert response.url == reverse('mesa-cargar-resultados',
                                   args=[e2.id, m2.numero])
Exemplo n.º 2
0
def test_siguiente_happy_path_parcial_y_total_con_modo_ub(
        db, fiscal_client, admin_user, settings):
    # Este test no es del todo realista porque se lo ejecuta con la cantidad de cargas/identificaciones
    # necesarias para consolidar en 1, pero al menos prueba que se siga el circuito con modo_ub=True.
    settings.MIN_COINCIDENCIAS_CARGAS = 1
    settings.MIN_COINCIDENCIAS_IDENTIFICACION = 1
    modo_ub_querry_string = '?modo_ub=True'
    mesa = MesaFactory()
    from adjuntos.models import PreIdentificacion
    from scheduling.models import ColaCargasPendientes
    p = PreIdentificacion(fiscal=admin_user.fiscal,
                          distrito=mesa.circuito.seccion.distrito)
    p.save()
    a = AttachmentFactory(status='sin_identificar', pre_identificacion=p)
    scheduler()
    assert ColaCargasPendientes.largo_cola() == 1
    response = fiscal_client.get(
        reverse('siguiente-accion') + modo_ub_querry_string)

    assert response.status_code == HTTPStatus.FOUND
    # Me manda a idenficarlas con modo_ub
    assert response.url == reverse('asignar-mesa',
                                   args=[a.id]) + modo_ub_querry_string

    assert ColaCargasPendientes.largo_cola() == 0

    # La identifico.
    a.mesa = mesa
    a.status = 'identificada'
    a.save()
    mc1 = MesaCategoriaFactory(categoria__requiere_cargas_parciales=True,
                               coeficiente_para_orden_de_carga=1,
                               mesa=mesa)
    scheduler()

    assert ColaCargasPendientes.largo_cola() == 1

    response = fiscal_client.get(
        reverse('siguiente-accion') + modo_ub_querry_string)
    assert response.status_code == HTTPStatus.FOUND
    assert response.url == reverse('carga-parcial',
                                   args=[mc1.id]) + modo_ub_querry_string

    carga = CargaFactory(mesa_categoria=mc1, tipo='parcial', origen='csv')
    consumir_novedades_carga()
    scheduler()
    mc1.refresh_from_db()
    assert mc1.status == MesaCategoria.STATUS.parcial_consolidada_dc  # Porque la cant de cargas está en 1.
    assert mc1.carga_testigo == carga
    mc1.desasignar_a_fiscal()
    response = fiscal_client.get(
        reverse('siguiente-accion') + modo_ub_querry_string)
    assert response.url == reverse('carga-total',
                                   args=[mc1.id]) + modo_ub_querry_string

    carga = CargaFactory(mesa_categoria=mc1, tipo='total', origen='csv')
    consumir_novedades_carga()
    scheduler()
    mc1.refresh_from_db()
    assert mc1.status == MesaCategoria.STATUS.total_consolidada_dc  # Porque la cant de cargas está en 1.
    assert mc1.carga_testigo == carga
    response = fiscal_client.get(
        reverse('siguiente-accion') + modo_ub_querry_string)
    # No hay actas para cargar, vuelta a empezar.
    assert response.status_code == HTTPStatus.OK
    assert 'No hay actas para cargar' in str(response.content)
Exemplo n.º 3
0
def test_datos_preidentificaciones(db, settings):
    settings.MIN_COINCIDENCIAS_IDENTIFICACION = 2
    settings.DISTRITO_PBA = '2'

    # 50 mesas: 20 pba, 15 caba, 15 catamarca
    data = DataTresDistritos(settings.DISTRITO_PBA)

    # 20 preidentificaciones
    preidents_pba = [PreidentificacionFactory(distrito=data.distrito_pba) for ix in range(12)] 
    preidents_caba = [PreidentificacionFactory(distrito=data.distrito_caba) for ix in range(8)]

    # 40 fotos:
    # - 14 / 5 / 2 identificadas a mesas pba / caba / catamarca
    # - 3 con problemas
    # - 6 en proceso de identificación
    # - 10 sin acciones
    fotos = []
    for ix in range(40):
        foto = AttachmentFactory()
        fotos.append(foto)
        if (ix < 14):
            identificar(foto, data.mesas_pba[ix], data.fiscales[0])
            identificar(foto, data.mesas_pba[ix], data.fiscales[1])
            if (ix < 5):
                foto.pre_identificacion = preidents_pba[ix]
                foto.save(update_fields=['pre_identificacion'])
        elif (ix < 19):
            identificar(foto, data.mesas_caba[ix-14], data.fiscales[2])
            identificar(foto, data.mesas_caba[ix-14], data.fiscales[3])
            if (ix < 17):
                foto.pre_identificacion = preidents_caba[ix-14]
                foto.save(update_fields=['pre_identificacion'])
        elif (ix < 21):
            identificar(foto, data.mesas_cat[ix-19], data.fiscales[4])
            identificar(foto, data.mesas_cat[ix-19], data.fiscales[5])
        elif (ix < 24):
            reportar_problema_attachment(foto, data.fiscales[6])
            reportar_problema_attachment(foto, data.fiscales[7])
        elif (ix < 30):
            identificar(foto, data.mesas_pba[ix-10], data.fiscales[8])
            if (ix < 26):
                foto.pre_identificacion = preidents_pba[ix-19]
                foto.save(update_fields=['pre_identificacion'])
        elif (ix < 35):
            foto.pre_identificacion = preidents_pba[ix-23]
            foto.save(update_fields=['pre_identificacion'])
        elif (ix < 40):
            foto.pre_identificacion = preidents_caba[ix-32]
            foto.save(update_fields=['pre_identificacion'])

    consumir_novedades()
    generador_nacional = GeneradorDatosPreidentificaciones()
    generador_pba = GeneradorDatosPreidentificaciones(
        PreIdentificacion.objects.filter(distrito__numero=settings.DISTRITO_PBA))
    generador_nacional.calcular()
    generador_pba.calcular()

    assert generador_nacional.cantidad_total == 20
    assert generador_nacional.identificadas == 8
    assert generador_nacional.sin_identificar == 12
    assert generador_pba.cantidad_total == 12
    assert generador_pba.identificadas == 5
    assert generador_pba.sin_identificar == 7