# Path: APITaxi2/redis_backend.py
# class _Taxi:
# class _TaxiLocationUpdate:
# class Location:
# def get_taxi(taxi_id, operator_name):
# def get_timestamps_entries_between(start_timestamp, end_timestamp):
# def list_taxis(start_timestamp, end_timestamp):
# def set_taxi_availability(taxi_id, taxi_operator, available):
# def taxis_locations_by_operator(lon, lat, distance):
# def log_hail(hail_id, http_method, request_payload, hail_initial_status,
#              request_user=None, response_payload=None,
#              response_status_code=None, hail_final_status=None):
#     PREFIX = len(b'taxi:')


import time
from APITaxi2 import redis_backend
    redis_backend.set_taxi_availability('taxi_id', 'operator', False)
    assert len(app.redis.zrange('not_available', 0, -1)) == 1

    # Not available, must be removed from ZSET not_available
    redis_backend.set_taxi_availability('taxi_id', 'operator', True)
    assert len(app.redis.zrange('not_available', 0, -1)) == 0


def test_taxis_locations_by_operator(app):
    now = int(time.time())
    app.redis.geoadd('geoindex_2', [2.35000, 48.86000, 'taxi1:operator1'])
    app.redis.zadd('timestamps', {'taxi1:operator1': now})

    app.redis.geoadd('geoindex_2', [2.35001, 48.86001, 'taxi1:operator2'])
    app.redis.zadd('timestamps', {'taxi1:operator2': now})

    app.redis.geoadd('geoindex_2', [2.35002, 48.86002, 'taxi2:operator3'])
    app.redis.zadd('timestamps', {'taxi2:operator3': now})

    # Outside of range
    app.redis.geoadd('geoindex_2', [2.3, 47, 'taxi3:operator4'])
    app.redis.zadd('timestamps', {'taxi3:operator4': now})

    res = redis_backend.taxis_locations_by_operator(2.35, 48.86, 500)
    assert len(res) == 2
    assert len(res['taxi1']) == 2
    assert len(res['taxi2']) == 1


def test_log_hail(app, moteur):

# Path: APITaxi2/redis_backend.py
# class _Taxi:
# class _TaxiLocationUpdate:
# class Location:
# def get_taxi(taxi_id, operator_name):
# def get_timestamps_entries_between(start_timestamp, end_timestamp):
# def list_taxis(start_timestamp, end_timestamp):
# def set_taxi_availability(taxi_id, taxi_operator, available):
# def taxis_locations_by_operator(lon, lat, distance):
# def log_hail(hail_id, http_method, request_payload, hail_initial_status,
#              request_user=None, response_payload=None,
#              response_status_code=None, hail_final_status=None):
#     PREFIX = len(b'taxi:')


# Path: APITaxi2/tests/test_redis_backend.py
import time
from APITaxi2 import redis_backend

    redis_backend.set_taxi_availability('taxi_id', 'operator', False)
    assert len(app.redis.zrange('not_available', 0, -1)) == 1

    # Not available, must be removed from ZSET not_available
    redis_backend.set_taxi_availability('taxi_id', 'operator', True)
    assert len(app.redis.zrange('not_available', 0, -1)) == 0


def test_taxis_locations_by_operator(app):
    now = int(time.time())
    app.redis.geoadd('geoindex_2', [2.35000, 48.86000, 'taxi1:operator1'])
    app.redis.zadd('timestamps', {'taxi1:operator1': now})

    app.redis.geoadd('geoindex_2', [2.35001, 48.86001, 'taxi1:operator2'])
    app.redis.zadd('timestamps', {'taxi1:operator2': now})

    app.redis.geoadd('geoindex_2', [2.35002, 48.86002, 'taxi2:operator3'])
    app.redis.zadd('timestamps', {'taxi2:operator3': now})

    # Outside of range
    app.redis.geoadd('geoindex_2', [2.3, 47, 'taxi3:operator4'])
    app.redis.zadd('timestamps', {'taxi3:operator4': now})

    res = redis_backend.taxis_locations_by_operator(2.35, 48.86, 500)
    assert len(res) == 2
    assert len(res['taxi1']) == 2
    assert len(res['taxi2']) == 1


def test_log_hail(app, moteur):

    redis_backend.log_hail(