# Path: APITaxi_models2/unittest/factories.py
# class BaseFactory(factory.alchemy.SQLAlchemyModelFactory):
#     class Meta:
# class RoleFactory(BaseFactory):
#     class Meta:
# class UserFactory(BaseFactory):
#     class Meta:
# class RolesUsersFactory(BaseFactory):
#     class Meta:
# class CustomerFactory(BaseFactory):
#     class Meta:
# class DepartementFactory(BaseFactory):
#     class Meta:
# class TownFactory(BaseFactory):
#     class Meta:
#     class Params:
# class ZUPCFactory(BaseFactory):
#     class Meta:
#     class Params:
# class DriverFactory(BaseFactory):
#     class Meta:
# class VehicleDescriptionFactory(BaseFactory):
#     class Meta:
# class VehicleFactory(BaseFactory):
#     class Meta:
# class ADSFactory(BaseFactory):
#     class Meta:
# class TaxiFactory(BaseFactory):
#     class Meta:
# class HailFactory(BaseFactory):
#     class Meta:
#     def descriptions(self, create, extracted, **kwargs):
# 
# 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:')


from APITaxi_models2.unittest import factories
from APITaxi2 import redis_backend
        redis_taxi = redis_backend.get_taxi(taxis[36].id, operateur.user.email)  # Pick a random one
        assert redis_taxi
        assert redis_taxi.lon == 2.35 and redis_taxi.lat == 48.86

    def test_too_many(self, operateur):
        taxis = factories.TaxiFactory.create_batch(51, added_by=operateur.user)
        response = operateur.client.post('/geotaxi', json={
            'data': [{
                'positions': [
                    {'taxi_id': taxi.id, 'lon': 2.35, 'lat': 48.86}
                    for taxi in taxis
                ]
            }]
        })
        assert response.status_code == 400
        assert 'positions' in response.json['errors']['data']['0']

    def test_ok_taxi_two_operators(self, app, operateur, QueriesTracker):
        """Taxi is registered with two operators, but reports its location with
        only one.
        """
        vehicle = factories.VehicleFactory(descriptions=[])
        factories.VehicleDescriptionFactory(
            vehicle=vehicle,
            added_by=operateur.user,
        )
        # VehicleDescription related to another operator
        factories.VehicleDescriptionFactory(
            vehicle=vehicle,
        )

# Path: APITaxi_models2/unittest/factories.py
# class BaseFactory(factory.alchemy.SQLAlchemyModelFactory):
#     class Meta:
# class RoleFactory(BaseFactory):
#     class Meta:
# class UserFactory(BaseFactory):
#     class Meta:
# class RolesUsersFactory(BaseFactory):
#     class Meta:
# class CustomerFactory(BaseFactory):
#     class Meta:
# class DepartementFactory(BaseFactory):
#     class Meta:
# class TownFactory(BaseFactory):
#     class Meta:
#     class Params:
# class ZUPCFactory(BaseFactory):
#     class Meta:
#     class Params:
# class DriverFactory(BaseFactory):
#     class Meta:
# class VehicleDescriptionFactory(BaseFactory):
#     class Meta:
# class VehicleFactory(BaseFactory):
#     class Meta:
# class ADSFactory(BaseFactory):
#     class Meta:
# class TaxiFactory(BaseFactory):
#     class Meta:
# class HailFactory(BaseFactory):
#     class Meta:
#     def descriptions(self, create, extracted, **kwargs):
# 
# 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_geotaxi.py
from APITaxi_models2.unittest import factories
from APITaxi2 import redis_backend

        redis_taxi = redis_backend.get_taxi(taxis[36].id, operateur.user.email)  # Pick a random one
        assert redis_taxi
        assert redis_taxi.lon == 2.35 and redis_taxi.lat == 48.86

    def test_too_many(self, operateur):
        taxis = factories.TaxiFactory.create_batch(51, added_by=operateur.user)
        response = operateur.client.post('/geotaxi', json={
            'data': [{
                'positions': [
                    {'taxi_id': taxi.id, 'lon': 2.35, 'lat': 48.86}
                    for taxi in taxis
                ]
            }]
        })
        assert response.status_code == 400
        assert 'positions' in response.json['errors']['data']['0']

    def test_ok_taxi_two_operators(self, app, operateur, QueriesTracker):
        """Taxi is registered with two operators, but reports its location with
        only one.
        """
        vehicle = factories.VehicleFactory(descriptions=[])
        factories.VehicleDescriptionFactory(
            vehicle=vehicle,
            added_by=operateur.user,
        )
        # VehicleDescription related to another operator
        factories.VehicleDescriptionFactory(
            vehicle=vehicle,
        )

        taxi = factories.TaxiFactory(vehicle=vehicle)