Beispiel #1
0
def parking_space_availability_cykleo_get_informations_test():
    webservice_response = {
        '2': {
            "station": {
                "assetStation": {
                    "coordinate": {},
                    "organization": 1,
                    "commercialNumber": 1,
                    "id": 1,
                    "commercialName": "station 1"
                },
                "status": "IN_SERVICE",
                "id": 1
            },
            "availableClassicBikeCount": 3,
            "id": 1,
            "availableElectricBikeCount": 1,
            "availableDockCount": 2
        }
    }
    provider = CykleoProvider('http://bob', network, 'big', 'big', {'CYKLEO'})
    provider._call_webservice = MagicMock(return_value=webservice_response)
    assert provider.get_informations(poi) == Stands(2, 4, StandsStatus.open)
    assert provider.get_informations(poi_with_0) == Stands(
        2, 4, StandsStatus.open)
    provider._call_webservice = MagicMock(return_value=None)
    assert provider.get_informations(poi) == Stands(0, 0,
                                                    StandsStatus.unavailable)
    assert provider.get_informations(poi_with_0) == Stands(
        0, 0, StandsStatus.unavailable)

    invalid_poi = {}
    assert provider.get_informations(invalid_poi) == Stands(
        0, 0, StandsStatus.unavailable)
Beispiel #2
0
def parking_space_availability_cykleo_get_informations_with_status_Closed_test(
):
    webservice_response = {
        '2': {
            "station": {
                "assetStation": {
                    "coordinate": {},
                    "organization": 1,
                    "commercialNumber": 1,
                    "id": 1,
                    "commercialName": "station 1"
                },
                "status": "DISCONNECTED",
                "id": 1
            },
            "availableClassicBikeCount": 3,
            "id": 1,
            "availableElectricBikeCount": 1,
            "availableDockCount": 2
        }
    }
    provider = CykleoProvider('http://bob', network, 'big', 'big', {'CYKLEO'})
    provider._call_webservice = MagicMock(return_value=webservice_response)
    assert provider.get_informations(poi) == Stands(0, 0, 'UNAVAILABLE')
    assert provider.get_informations(poi_with_0) == Stands(0, 0, 'UNAVAILABLE')
Beispiel #3
0
def witout_available_dock_count_test():
    webservice_response = {
        '2': {
            "station": {
                "assetStation": {
                    "coordinate": {},
                    "organization": 1,
                    "commercialNumber": 1,
                    "id": 1,
                    "commercialName": "station 1"
                },
                "status": "IN_SERVICE",
                "id": 1
            },
            "id": 1,
            "availableElectricBikeCount": 1,
        }
    }
    provider = CykleoProvider('http://bob', network, 'big', 'big', {'CYKLEO'})
    provider._call_webservice = MagicMock(return_value=webservice_response)
    assert not provider.get_informations(poi)
    assert not provider.get_informations(poi_with_0)
Beispiel #4
0
def available_classic_bike_count_only_test():
    webservice_response = {
        '2': {
            "station": {
                "assetStation": {
                    "coordinate": {},
                    "organization": 1,
                    "commercialNumber": 1,
                    "id": 1,
                    "commercialName": "station 1"
                },
                "status": "IN_SERVICE",
                "id": 1
            },
            "id": 1,
            "availableClassicBikeCount": 1,
            "availableDockCount": 2
        }
    }
    provider = CykleoProvider('http://bob', network, 'big', 'big', {'CYKLEO'})
    provider._call_webservice = MagicMock(return_value=webservice_response)
    assert provider.get_informations(poi) == Stands(2, 1, 'OPEN')
    assert provider.get_informations(poi_with_0) == Stands(2, 1, 'OPEN')