# 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




def test_get_taxi(app):
    now = int(time.time())

    assert redis_backend.get_taxi('taxi_id', 'operator') is None

    app.redis.hset('taxi:taxi_id', 'operator', f'{now} 48.86 2.35 free phone 2')

    ret = redis_backend.get_taxi('taxi_id', 'operator')
    assert ret
    assert ret.timestamp == now
    assert ret.lat == 48.86
    assert ret.lon == 2.35
    assert ret.status == 'free'
    assert ret.device == 'phone'

# 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





def test_get_taxi(app):
    now = int(time.time())

    assert redis_backend.get_taxi('taxi_id', 'operator') is None

    app.redis.hset('taxi:taxi_id', 'operator', f'{now} 48.86 2.35 free phone 2')

    ret = redis_backend.get_taxi('taxi_id', 'operator')
    assert ret
    assert ret.timestamp == now
    assert ret.lat == 48.86
    assert ret.lon == 2.35
    assert ret.status == 'free'
    assert ret.device == 'phone'

    assert ret.version == 2