コード例 #1
0
def parking_space_availability_atos_get_all_stands_urlerror_test():
    """
    Atos webservice error should raise an URLError exception
    """
    provider = AtosProvider(u'10', u'vélitul', u'https://error.fake.com?wsdl', {'keolis'})

    with pytest.raises(Exception):
        provider.get_all_stands()
コード例 #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
コード例 #3
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
    all_stands_list.append(stands)
    stands2 = lambda: None
    stands2.libelle = '2'
    stands2.nbPlacesDispo = 5
    stands2.nbVelosDispo = 9
    all_stands_list.append(stands2)

    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)
    provider.get_client = MagicMock(return_value=client)
    all_stands = provider.get_all_stands()
    assert len(all_stands) == 2
    assert isinstance(all_stands.get('2'), Stands)