def test_no_se_reportan_eventos_cuando_no_se_excede_la_velocidad_maxima(self):

        recorrido =  [
                    (-34.551882, -58.463000),
                    (-34.551882, -58.463500),
                    (-34.551882, -58.464000),
                    (-34.551882, -58.464100),
                    (-34.551882, -58.464200),
                    (-34.551882, -58.464300),
                    (-34.551882, -58.464400),
                    ]

        distancia = CalculadorDistanciasPorCoordenadas().obtener_distancia((-34.551882, -58.463000),
                                                                    (-34.551882, -58.463500))


        gps = self.un_gps_que_notifique_el_recorrido(recorrido)


        zona_geografica = ZonaGeografica.definida_por((-34.551000, -58.462000), (-34.553882, -58.762591))
        catalogo_de_velocidades_maximas = dict()


        catalogo_de_velocidades_maximas[zona_geografica] =  Velocidad.nueva_con_km_por_h(magnitud = 145)
        proveedor_velocidad_maxima = ProveedorVelocidadMaxima.nuevo(catalogo_de_velocidades_maximas=catalogo_de_velocidades_maximas)


        DetectorDeExcesoDeVelocidad.nuevo_con(gps=gps, estrategia_de_reporte_de_eventos=self,
                                              proveedor_velocidad_maxima=proveedor_velocidad_maxima, porcentaje_de_velocidad_maxima= 10, distancia_excedido=Distance(0.1))

        gps.activar()

        self.assertEquals(len(self.eventos_registrados), 0)
    def test_se_reportan_dos_eventos_cuando_el_recorrido_se_excede_en_velocidad_mas_de_200_metros(self):



        recorrido =  [
                    (-34.551882, -58.463000),
                    (-34.551882, -58.463500),
                    (-34.551882, -58.464000),
                    (-34.551882, -58.464500),
                    (-34.551882, -58.465000),
                    (-34.551882, -58.465500),
                    (-34.551882, -58.466000),
                    (-34.551882, -58.466500),
                    ]

        gps = self.un_gps_que_notifique_el_recorrido(recorrido)

        zona_geografica = ZonaGeografica.definida_por((-34.551000, -58.462000), (-34.553882, -58.762591))
        catalogo_de_velocidades_maximas = dict()

        catalogo_de_velocidades_maximas[zona_geografica] = Velocidad.nueva_con_km_por_h(magnitud = 94)
        proveedor_velocidad_maxima = ProveedorVelocidadMaxima.nuevo(catalogo_de_velocidades_maximas=catalogo_de_velocidades_maximas)


        DetectorDeExcesoDeVelocidad.nuevo_con(gps=gps, estrategia_de_reporte_de_eventos=self,
                                              proveedor_velocidad_maxima=proveedor_velocidad_maxima ,porcentaje_de_velocidad_maxima= 10, distancia_excedido=Distance(0.1))

        gps.activar()

        self.assertEquals(len(self.eventos_registrados), 3)
    def test_no_se_encuentra_velocidad_maxima_para_alguna_coordenada(self):
        try:
            recorrido =  [
                        (-34.551882, -58.463000),
                        (-34.551882, -58.463500),
                        (-34.551882, -58.464000),
                        (-34.551882, -58.464100),
                        (-34.551882, -58.464200),
                        (-34.551882, -58.464300),
                        (-34.551882, -58.464400),
                        ]

            gps = self.un_gps_que_notifique_el_recorrido(recorrido)
            zona_geografica = ZonaGeografica.definida_por((-34.551000, -58.464000), (-34.553882, -58.762591))
            catalogo_de_velocidades_maximas = dict()


            catalogo_de_velocidades_maximas[zona_geografica] = Velocidad.nueva_con_km_por_h(magnitud = 94)
            proveedor_velocidad_maxima = ProveedorVelocidadMaxima.nuevo(catalogo_de_velocidades_maximas=catalogo_de_velocidades_maximas)

            DetectorDeExcesoDeVelocidad.nuevo_con(gps=gps, estrategia_de_reporte_de_eventos=self,
                                                  proveedor_velocidad_maxima=proveedor_velocidad_maxima ,porcentaje_de_velocidad_maxima= 10, distancia_excedido=Distance(0.1))

            gps.activar()
            self.assertEquals(len(self.eventos_registrados), 0)

        except RuntimeError, e:
            print e
Ejemplo n.º 4
0
from detectores.detector_de_zona_peligrosa import DetectorDeViajeAZonaPeligrosa
from fisica.aceleracion import Aceleracion
from fisica.velocidad import Velocidad
from geolocalizacion.proveedor_velocidad_maxima import ProveedorVelocidadMaxima
from geolocalizacion.zona_geografica import ZonaGeografica


ZONAS_PELIGROSAS = [
    ZonaGeografica.definida_por((34.551882, 58.465000), (34.551882, 58.465600)),
    ZonaGeografica.definida_por((34.551882, 58.463000), (34.551882, 58.463500)),
]


zona_geografica = ZonaGeografica.definida_por((34.551000, 58.462000), (34.553882, 58.762591))
catalogo_de_velocidades_maximas = dict()
catalogo_de_velocidades_maximas[zona_geografica] = Velocidad.nueva_con_km_por_h(magnitud=145)

PROVEEDOR_DE_VELOCIDAD_MAXIMA = ProveedorVelocidadMaxima.nuevo(
    catalogo_de_velocidades_maximas=catalogo_de_velocidades_maximas
)


ASEGURADOS = [Asegurado.con(nombre="Carlos Perez")]

CONFIGURACION_DE_DETECTORES = [
    {"tipo": DetectorDeViajeAZonaPeligrosa, "parametros": {"zonas_peligrosas": ZONAS_PELIGROSAS}},
    {"tipo": DetectorDeViaje, "parametros": {}},
    {
        "tipo": DetectorDeExcesoDeVelocidad,
        "parametros": {
            "proveedor_velocidad_maxima": PROVEEDOR_DE_VELOCIDAD_MAXIMA,