Example #1
0
def parking_space_availability_atos_get_informations_with_closed_status_test():
    """
    The service returns realtime stand information or stand with status='unavailable' if an error occured
    """

    stand_2 = Stands(5, 9, StandsStatus.closed)
    all_stands = {'1': Stands(4, 8, StandsStatus.open), '2': stand_2}
    provider = AtosProvider(u'10', u'vélitul', u'https://webservice.atos.com?wsdl', {'keolis'})
    provider._get_all_stands = MagicMock(return_value=all_stands)
    assert provider.get_informations(poi) == Stands(0, 0, StandsStatus.closed)
    invalid_poi = {}
    assert provider.get_informations(invalid_poi) == Stands(0, 0, StandsStatus.unavailable)
Example #2
0
def parking_space_availability_atos_get_informations_test():
    """
    Atos validate return good stands informations or None if an error occured
    """
    stands = Stands(5, 9)
    all_stands = {'1': Stands(4, 8), '2': stands}
    provider = AtosProvider(u'10', u'vélitul',
                            u'https://webservice.atos.com?wsdl', {'keolis'})
    provider.get_all_stands = MagicMock(return_value=all_stands)
    assert provider.get_informations(poi) == stands
    provider.get_all_stands = MagicMock(
        side_effect=WebFault('fake fault', 'mock'))
    assert provider.get_informations(poi) is None
Example #3
0
def parking_space_availability_atos_get_informations_test():
    """
    The service returns realtime stand information or stand with status='unavailable' if an error occured
    """
    stand_2 = Stands(5, 9, StandsStatus.open)
    all_stands = {'1': Stands(4, 8, StandsStatus.open), '2': stand_2}
    provider = AtosProvider(u'10', u'vélitul', u'https://webservice.atos.com?wsdl', {'keolis'})
    provider._get_all_stands = MagicMock(return_value=all_stands)
    assert provider.get_informations(poi) == stand_2
    invalid_poi = {}
    assert provider.get_informations(invalid_poi) == Stands(0, 0, StandsStatus.unavailable)

    poi_blur_ref = {'properties': {'ref': '02'}}
    assert provider.get_informations(poi_blur_ref) == stand_2

    provider._get_all_stands = MagicMock(side_effect=Exception('cannot access service'))
    assert provider.get_informations(poi) == Stands(0, 0, StandsStatus.unavailable)
Example #4
0
def parking_space_availability_atos_get_informations_test():
    """
    Atos validate return good stands informations or None if an error occured
    """
    stands = Stands(5, 9)
    all_stands = {'1': Stands(4, 8), '2': stands}
    provider = AtosProvider(u'10', u'vélitul',
                            u'https://webservice.atos.com?wsdl', {'keolis'})
    provider._get_all_stands = MagicMock(return_value=all_stands)
    assert provider.get_informations(poi) == stands
    invalid_poi = {}
    assert provider.get_informations(invalid_poi) is None

    poi_blur_ref = {'properties': {'ref': '02'}}
    assert provider.get_informations(poi_blur_ref) == stands

    provider._get_all_stands = MagicMock(
        side_effect=Exception('cannot access service'))
    assert provider.get_informations(poi) is None
Example #5
0
def parking_space_availability_atos_get_all_stands_test():
    """
    Atos validate transformation of webservice result
    """
    stands = lambda: None
    all_stands_list = []
    stands.libelle = '1'
    stands.nbPlacesDispo = 4
    stands.nbVelosDispo = 8
    stands.etatConnexion = 'CONNECTEE'
    all_stands_list.append(stands)
    stands2 = lambda: None
    stands2.libelle = '2'
    stands2.nbPlacesDispo = 5
    stands2.nbVelosDispo = 9
    stands2.etatConnexion = 'CONNECTEE'
    all_stands_list.append(stands2)
    stands3 = lambda: None
    stands3.libelle = '3'
    stands3.nbPlacesDispo = 10
    stands3.nbVelosDispo = 20
    stands3.etatConnexion = 'DECONNECTEE'
    all_stands_list.append(stands3)

    provider = AtosProvider(u'10', u'vélitul',
                            u'https://webservice.atos.com?wsdl', {'keolis'})
    client = lambda: None
    client.service = lambda: None
    client.service.getSummaryInformationTerminals = MagicMock(
        return_value=all_stands_list)

    @contextmanager
    def mock_get_client():
        yield client

    provider._get_client = mock_get_client

    all_stands = provider._get_all_stands()
    assert len(all_stands) == 3
    assert isinstance(all_stands.get('2'), Stands)

    # The status of stand=3 is converted to status navitia='unavailable' from 'DECONNECTEE'
    # and other attributs are initialized to 0.
    stand = provider.get_informations('3')
    assert stand == Stands(0, 0, StandsStatus.unavailable)