Use double quotes
This commit is contained in:
parent
7b32ffc599
commit
ea8f1a13e3
22 changed files with 2464 additions and 2466 deletions
|
|
@ -15,7 +15,7 @@ class AddressFactory(alchemy.SQLAlchemyModelFactory):
|
|||
|
||||
class Meta:
|
||||
model = db.Address
|
||||
sqlalchemy_get_or_create = ('id',)
|
||||
sqlalchemy_get_or_create = ("id",)
|
||||
|
||||
id = factory.Sequence(lambda num: num)
|
||||
created_at = factory.LazyFunction(utils.early_in_the_morning)
|
||||
|
|
@ -28,13 +28,13 @@ class AddressFactory(alchemy.SQLAlchemyModelFactory):
|
|||
|
||||
# Mimic a Google Maps Place ID with just random characters.
|
||||
place_id = factory.LazyFunction(
|
||||
lambda: ''.join(random.choice(string.ascii_lowercase) for _ in range(20)),
|
||||
lambda: "".join(random.choice(string.ascii_lowercase) for _ in range(20)),
|
||||
)
|
||||
|
||||
# Place the addresses somewhere in downtown Paris.
|
||||
latitude = factory.Faker('coordinate', center=48.855, radius=0.01)
|
||||
longitude = factory.Faker('coordinate', center=2.34, radius=0.03)
|
||||
latitude = factory.Faker("coordinate", center=48.855, radius=0.01)
|
||||
longitude = factory.Faker("coordinate", center=2.34, radius=0.03)
|
||||
# city -> set by the `make_address` fixture as there is only one `city`
|
||||
city_name = 'Paris'
|
||||
city_name = "Paris"
|
||||
zip_code = factory.LazyFunction(lambda: random.randint(75001, 75020))
|
||||
street = factory.Faker('street_address', locale='fr_FR')
|
||||
street = factory.Faker("street_address", locale="fr_FR")
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ class CourierFactory(alchemy.SQLAlchemyModelFactory):
|
|||
|
||||
class Meta:
|
||||
model = db.Courier
|
||||
sqlalchemy_get_or_create = ('id',)
|
||||
sqlalchemy_get_or_create = ("id",)
|
||||
|
||||
id = factory.Sequence(lambda num: num)
|
||||
created_at = factory.LazyFunction(utils.early_in_the_morning)
|
||||
vehicle = 'bicycle'
|
||||
vehicle = "bicycle"
|
||||
historic_speed = 7.89
|
||||
capacity = 100
|
||||
pay_per_hour = 750
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ class CustomerFactory(alchemy.SQLAlchemyModelFactory):
|
|||
|
||||
class Meta:
|
||||
model = db.Customer
|
||||
sqlalchemy_get_or_create = ('id',)
|
||||
sqlalchemy_get_or_create = ("id",)
|
||||
|
||||
id = factory.Sequence(lambda num: num)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class AdHocOrderFactory(alchemy.SQLAlchemyModelFactory):
|
|||
|
||||
class Meta:
|
||||
model = db.Order
|
||||
sqlalchemy_get_or_create = ('id',)
|
||||
sqlalchemy_get_or_create = ("id",)
|
||||
|
||||
class Params:
|
||||
"""Define flags that overwrite some attributes.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class ReplayedOrderFactory(alchemy.SQLAlchemyModelFactory):
|
|||
|
||||
class Meta:
|
||||
model = db.ReplayedOrder
|
||||
sqlalchemy_get_or_create = ('simulation_id', 'order_id')
|
||||
sqlalchemy_get_or_create = ("simulation_id", "order_id")
|
||||
|
||||
# Generic columns
|
||||
# simulation -> set by the `make_replay_order` fixture for better control
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class RestaurantFactory(alchemy.SQLAlchemyModelFactory):
|
|||
|
||||
class Meta:
|
||||
model = db.Restaurant
|
||||
sqlalchemy_get_or_create = ('id',)
|
||||
sqlalchemy_get_or_create = ("id",)
|
||||
|
||||
id = factory.Sequence(lambda num: num)
|
||||
created_at = factory.LazyFunction(utils.early_in_the_morning)
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ def make_replay_order(make_order, simulation):
|
|||
"""
|
||||
if scheduled:
|
||||
if order and order.ad_hoc is False:
|
||||
raise RuntimeError('`order` must be scheduled')
|
||||
raise RuntimeError("`order` must be scheduled")
|
||||
elif order is None:
|
||||
order = make_order(scheduled=True)
|
||||
elif order is None:
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@ from velofy import db
|
|||
def city_data():
|
||||
"""The data for the one and only `City` object as a `dict`."""
|
||||
return {
|
||||
'id': 1,
|
||||
'name': 'Paris',
|
||||
'kml': "<?xml version='1.0' encoding='UTF-8'?> ...",
|
||||
'center_latitude': 48.856614,
|
||||
'center_longitude': 2.3522219,
|
||||
'northeast_latitude': 48.9021449,
|
||||
'northeast_longitude': 2.4699208,
|
||||
'southwest_latitude': 48.815573,
|
||||
'southwest_longitude': 2.225193,
|
||||
'initial_zoom': 12,
|
||||
"id": 1,
|
||||
"name": "Paris",
|
||||
"kml": "<?xml version='1.0' encoding='UTF-8'?> ...",
|
||||
"center_latitude": 48.856614,
|
||||
"center_longitude": 2.3522219,
|
||||
"northeast_latitude": 48.9021449,
|
||||
"northeast_longitude": 2.4699208,
|
||||
"southwest_latitude": 48.815573,
|
||||
"southwest_longitude": 2.225193,
|
||||
"initial_zoom": 12,
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -86,10 +86,10 @@ def pixel(grid):
|
|||
def simulation_data(city):
|
||||
"""The data for the one and only `ReplaySimulation` object as a `dict`."""
|
||||
return {
|
||||
'id': 1,
|
||||
'city': city,
|
||||
'strategy': 'best_possible_routing',
|
||||
'run': 0,
|
||||
"id": 1,
|
||||
"city": city,
|
||||
"strategy": "best_possible_routing",
|
||||
"run": 0,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class TestSpecialMethods:
|
|||
"""`ReplayedOrder` has a non-literal text representation."""
|
||||
result = repr(replayed_order)
|
||||
|
||||
assert result == f'<ReplayedOrder(#{replayed_order.actual.id})>'
|
||||
assert result == f"<ReplayedOrder(#{replayed_order.actual.id})>"
|
||||
|
||||
|
||||
@pytest.mark.db
|
||||
|
|
@ -50,7 +50,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_replayed_orders_to_replay_simulations',
|
||||
match="fk_replayed_orders_to_replay_simulations",
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ class TestConstraints:
|
|||
# Must delete without ORM as otherwise an UPDATE statement is emitted.
|
||||
stmt = sqla.delete(db.Order).where(db.Order.id == replayed_order.actual.id)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='fk_replayed_orders_to_orders'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="fk_replayed_orders_to_orders"):
|
||||
db_session.execute(stmt)
|
||||
|
||||
def test_delete_a_referenced_courier(
|
||||
|
|
@ -84,7 +84,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_replayed_orders_to_couriers',
|
||||
match="fk_replayed_orders_to_couriers",
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='either_ad_hoc_or_scheduled_order',
|
||||
match="either_ad_hoc_or_scheduled_order",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='either_ad_hoc_or_scheduled_order',
|
||||
match="either_ad_hoc_or_scheduled_order",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ad_hoc_orders_within_business_hours',
|
||||
match="ad_hoc_orders_within_business_hours",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ad_hoc_orders_within_business_hours',
|
||||
match="ad_hoc_orders_within_business_hours",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -165,7 +165,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='scheduled_orders_within_business_hours',
|
||||
match="scheduled_orders_within_business_hours",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='scheduled_orders_within_business_hours',
|
||||
match="scheduled_orders_within_business_hours",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -224,11 +224,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='scheduled_orders_within_business_hours',
|
||||
match="scheduled_orders_within_business_hours",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('minute', [min_ for min_ in range(60) if min_ % 15 != 0])
|
||||
@pytest.mark.parametrize("minute", [min_ for min_ in range(60) if min_ % 15 != 0])
|
||||
def test_scheduled_order_at_non_quarter_of_an_hour(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -253,11 +253,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='scheduled_orders_must_be_at_quart', # constraint name too long
|
||||
match="scheduled_orders_must_be_at_quart", # constraint name too long
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('second', list(range(1, 60)))
|
||||
@pytest.mark.parametrize("second", list(range(1, 60)))
|
||||
def test_scheduled_order_at_non_quarter_of_an_hour_by_seconds(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -283,7 +283,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='scheduled_orders_must_be_at_quart', # constraint name too long
|
||||
match="scheduled_orders_must_be_at_quart", # constraint name too long
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -315,25 +315,25 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='scheduled_orders_not_within_30_minutes',
|
||||
match="scheduled_orders_not_within_30_minutes",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'column',
|
||||
"column",
|
||||
[
|
||||
'restaurant_notified_at',
|
||||
'restaurant_confirmed_at',
|
||||
'restaurant_ready_at',
|
||||
'dispatch_at',
|
||||
'courier', # not `.courier_id`
|
||||
'courier_notified_at',
|
||||
'courier_accepted_at',
|
||||
'reached_pickup_at',
|
||||
'pickup_at',
|
||||
'left_pickup_at',
|
||||
'reached_delivery_at',
|
||||
'delivery_at',
|
||||
"restaurant_notified_at",
|
||||
"restaurant_confirmed_at",
|
||||
"restaurant_ready_at",
|
||||
"dispatch_at",
|
||||
"courier", # not `.courier_id`
|
||||
"courier_notified_at",
|
||||
"courier_accepted_at",
|
||||
"reached_pickup_at",
|
||||
"pickup_at",
|
||||
"left_pickup_at",
|
||||
"reached_delivery_at",
|
||||
"delivery_at",
|
||||
],
|
||||
)
|
||||
def test_not_fully_simulated_order(self, db_session, replayed_order, column):
|
||||
|
|
@ -346,21 +346,21 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='either_cancelled_o', # constraint name too long
|
||||
match="either_cancelled_o", # constraint name too long
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'column',
|
||||
"column",
|
||||
[
|
||||
'restaurant_notified_at',
|
||||
'restaurant_confirmed_at',
|
||||
'restaurant_ready_at',
|
||||
'dispatch_at',
|
||||
'courier_id',
|
||||
'courier_notified_at',
|
||||
'courier_accepted_at',
|
||||
'reached_pickup_at',
|
||||
"restaurant_notified_at",
|
||||
"restaurant_confirmed_at",
|
||||
"restaurant_ready_at",
|
||||
"dispatch_at",
|
||||
"courier_id",
|
||||
"courier_notified_at",
|
||||
"courier_accepted_at",
|
||||
"reached_pickup_at",
|
||||
],
|
||||
)
|
||||
def test_simulated_cancellation(self, db_session, replayed_order, column):
|
||||
|
|
@ -381,8 +381,8 @@ class TestConstraints:
|
|||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'column',
|
||||
['pickup_at', 'left_pickup_at', 'reached_delivery_at', 'delivery_at'],
|
||||
"column",
|
||||
["pickup_at", "left_pickup_at", "reached_delivery_at", "delivery_at"],
|
||||
)
|
||||
def test_no_simulated_cancellation_after_pickup(
|
||||
self,
|
||||
|
|
@ -398,10 +398,10 @@ class TestConstraints:
|
|||
# Set all timestamps after `.reached_pickup_at` to NULL
|
||||
# except the one under test.
|
||||
for unset_column in (
|
||||
'pickup_at',
|
||||
'left_pickup_at',
|
||||
'reached_delivery_at',
|
||||
'delivery_at',
|
||||
"pickup_at",
|
||||
"left_pickup_at",
|
||||
"reached_delivery_at",
|
||||
"delivery_at",
|
||||
):
|
||||
if unset_column != column:
|
||||
setattr(replayed_order, unset_column, None)
|
||||
|
|
@ -410,11 +410,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='cancellations_may_only_occur_befo', # constraint name too long
|
||||
match="cancellations_may_only_occur_befo", # constraint name too long
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('duration', [-1, 3601])
|
||||
@pytest.mark.parametrize("duration", [-1, 3601])
|
||||
def test_estimated_prep_duration_out_of_range(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -427,11 +427,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='between_0', # constraint name too long
|
||||
match="between_0", # constraint name too long
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('duration', [1, 59, 119, 3599])
|
||||
@pytest.mark.parametrize("duration", [1, 59, 119, 3599])
|
||||
def test_estimated_prep_duration_not_whole_minute(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -444,11 +444,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='must_be_w', # constraint name too long
|
||||
match="must_be_w", # constraint name too long
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('utilization', [-1, 101])
|
||||
@pytest.mark.parametrize("utilization", [-1, 101])
|
||||
def test_utilization_out_of_range(self, db_session, replayed_order, utilization):
|
||||
"""Insert an instance with invalid data."""
|
||||
replayed_order.utilization = utilization
|
||||
|
|
@ -456,12 +456,12 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='between_0_and_100',
|
||||
match="between_0_and_100",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('column', ['restaurant_notified_at', 'dispatch_at'])
|
||||
@pytest.mark.parametrize('hour', [0, 10])
|
||||
@pytest.mark.parametrize("column", ["restaurant_notified_at", "dispatch_at"])
|
||||
@pytest.mark.parametrize("hour", [0, 10])
|
||||
def test_order_dispatched_in_non_business_hour(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -480,60 +480,60 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='business_hours',
|
||||
match="business_hours",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'comparison',
|
||||
"comparison",
|
||||
[
|
||||
'placed_at < restaurant_notified_at',
|
||||
'placed_at < restaurant_confirmed_at',
|
||||
'placed_at < restaurant_ready_at',
|
||||
'placed_at < dispatch_at',
|
||||
'placed_at < first_estimated_delivery_at',
|
||||
'placed_at < courier_notified_at',
|
||||
'placed_at < courier_accepted_at',
|
||||
'placed_at < reached_pickup_at',
|
||||
'placed_at < pickup_at',
|
||||
'placed_at < left_pickup_at',
|
||||
'placed_at < reached_delivery_at',
|
||||
'placed_at < delivery_at',
|
||||
'restaurant_notified_at < restaurant_confirmed_at',
|
||||
'restaurant_notified_at < restaurant_ready_at',
|
||||
'restaurant_notified_at < pickup_at',
|
||||
'restaurant_confirmed_at < restaurant_ready_at',
|
||||
'restaurant_confirmed_at < pickup_at',
|
||||
'restaurant_ready_at < pickup_at',
|
||||
'dispatch_at < first_estimated_delivery_at',
|
||||
'dispatch_at < courier_notified_at',
|
||||
'dispatch_at < courier_accepted_at',
|
||||
'dispatch_at < reached_pickup_at',
|
||||
'dispatch_at < pickup_at',
|
||||
'dispatch_at < left_pickup_at',
|
||||
'dispatch_at < reached_delivery_at',
|
||||
'dispatch_at < delivery_at',
|
||||
'courier_notified_at < courier_accepted_at',
|
||||
'courier_notified_at < reached_pickup_at',
|
||||
'courier_notified_at < pickup_at',
|
||||
'courier_notified_at < left_pickup_at',
|
||||
'courier_notified_at < reached_delivery_at',
|
||||
'courier_notified_at < delivery_at',
|
||||
'courier_accepted_at < reached_pickup_at',
|
||||
'courier_accepted_at < pickup_at',
|
||||
'courier_accepted_at < left_pickup_at',
|
||||
'courier_accepted_at < reached_delivery_at',
|
||||
'courier_accepted_at < delivery_at',
|
||||
'reached_pickup_at < pickup_at',
|
||||
'reached_pickup_at < left_pickup_at',
|
||||
'reached_pickup_at < reached_delivery_at',
|
||||
'reached_pickup_at < delivery_at',
|
||||
'pickup_at < left_pickup_at',
|
||||
'pickup_at < reached_delivery_at',
|
||||
'pickup_at < delivery_at',
|
||||
'left_pickup_at < reached_delivery_at',
|
||||
'left_pickup_at < delivery_at',
|
||||
'reached_delivery_at < delivery_at',
|
||||
"placed_at < restaurant_notified_at",
|
||||
"placed_at < restaurant_confirmed_at",
|
||||
"placed_at < restaurant_ready_at",
|
||||
"placed_at < dispatch_at",
|
||||
"placed_at < first_estimated_delivery_at",
|
||||
"placed_at < courier_notified_at",
|
||||
"placed_at < courier_accepted_at",
|
||||
"placed_at < reached_pickup_at",
|
||||
"placed_at < pickup_at",
|
||||
"placed_at < left_pickup_at",
|
||||
"placed_at < reached_delivery_at",
|
||||
"placed_at < delivery_at",
|
||||
"restaurant_notified_at < restaurant_confirmed_at",
|
||||
"restaurant_notified_at < restaurant_ready_at",
|
||||
"restaurant_notified_at < pickup_at",
|
||||
"restaurant_confirmed_at < restaurant_ready_at",
|
||||
"restaurant_confirmed_at < pickup_at",
|
||||
"restaurant_ready_at < pickup_at",
|
||||
"dispatch_at < first_estimated_delivery_at",
|
||||
"dispatch_at < courier_notified_at",
|
||||
"dispatch_at < courier_accepted_at",
|
||||
"dispatch_at < reached_pickup_at",
|
||||
"dispatch_at < pickup_at",
|
||||
"dispatch_at < left_pickup_at",
|
||||
"dispatch_at < reached_delivery_at",
|
||||
"dispatch_at < delivery_at",
|
||||
"courier_notified_at < courier_accepted_at",
|
||||
"courier_notified_at < reached_pickup_at",
|
||||
"courier_notified_at < pickup_at",
|
||||
"courier_notified_at < left_pickup_at",
|
||||
"courier_notified_at < reached_delivery_at",
|
||||
"courier_notified_at < delivery_at",
|
||||
"courier_accepted_at < reached_pickup_at",
|
||||
"courier_accepted_at < pickup_at",
|
||||
"courier_accepted_at < left_pickup_at",
|
||||
"courier_accepted_at < reached_delivery_at",
|
||||
"courier_accepted_at < delivery_at",
|
||||
"reached_pickup_at < pickup_at",
|
||||
"reached_pickup_at < left_pickup_at",
|
||||
"reached_pickup_at < reached_delivery_at",
|
||||
"reached_pickup_at < delivery_at",
|
||||
"pickup_at < left_pickup_at",
|
||||
"pickup_at < reached_delivery_at",
|
||||
"pickup_at < delivery_at",
|
||||
"left_pickup_at < reached_delivery_at",
|
||||
"left_pickup_at < delivery_at",
|
||||
"reached_delivery_at < delivery_at",
|
||||
],
|
||||
)
|
||||
def test_timestamps_unordered(
|
||||
|
|
@ -547,7 +547,7 @@ class TestConstraints:
|
|||
There are two special cases for this test case below,
|
||||
where other attributes on `replayed_order` must be unset.
|
||||
"""
|
||||
smaller, bigger = comparison.split(' < ')
|
||||
smaller, bigger = comparison.split(" < ")
|
||||
|
||||
assert smaller is not None
|
||||
|
||||
|
|
@ -556,7 +556,7 @@ class TestConstraints:
|
|||
|
||||
db_session.add(replayed_order)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='ordered_timestamps'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="ordered_timestamps"):
|
||||
db_session.commit()
|
||||
|
||||
def test_timestamps_unordered_scheduled(self, db_session, make_replay_order):
|
||||
|
|
@ -571,20 +571,20 @@ class TestConstraints:
|
|||
self.test_timestamps_unordered(
|
||||
db_session,
|
||||
replayed_pre_order,
|
||||
'placed_at < scheduled_delivery_at',
|
||||
"placed_at < scheduled_delivery_at",
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'comparison',
|
||||
"comparison",
|
||||
[
|
||||
'placed_at < cancelled_at',
|
||||
'restaurant_notified_at < cancelled_at',
|
||||
'restaurant_confirmed_at < cancelled_at',
|
||||
'restaurant_ready_at < cancelled_at',
|
||||
'dispatch_at < cancelled_at',
|
||||
'courier_notified_at < cancelled_at',
|
||||
'courier_accepted_at < cancelled_at',
|
||||
'reached_pickup_at < cancelled_at',
|
||||
"placed_at < cancelled_at",
|
||||
"restaurant_notified_at < cancelled_at",
|
||||
"restaurant_confirmed_at < cancelled_at",
|
||||
"restaurant_ready_at < cancelled_at",
|
||||
"dispatch_at < cancelled_at",
|
||||
"courier_notified_at < cancelled_at",
|
||||
"courier_accepted_at < cancelled_at",
|
||||
"reached_pickup_at < cancelled_at",
|
||||
],
|
||||
)
|
||||
def test_timestamps_unordered_cancelled(
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ class TestSpecialMethods:
|
|||
"""`ReplaySimulation` has a non-literal text representation."""
|
||||
result = repr(simulation)
|
||||
|
||||
assert result.startswith('<ReplaySimulation(')
|
||||
assert result.startswith("<ReplaySimulation(")
|
||||
assert simulation.city.name in result
|
||||
assert simulation.strategy in result
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class TestSpecialMethods:
|
|||
"""`Address` has a non-literal text representation."""
|
||||
result = repr(address)
|
||||
|
||||
assert result == f'<Address({address.street} in {address.city_name})>'
|
||||
assert result == f"<Address({address.street} in {address.city_name})>"
|
||||
|
||||
|
||||
@pytest.mark.db
|
||||
|
|
@ -47,7 +47,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_addresses_to_addresses_via_primary_id',
|
||||
match="fk_addresses_to_addresses_via_primary_id",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -61,11 +61,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_addresses_to_cities_via_city_id',
|
||||
match="fk_addresses_to_cities_via_city_id",
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
@pytest.mark.parametrize('latitude', [-91, 91])
|
||||
@pytest.mark.parametrize("latitude", [-91, 91])
|
||||
def test_invalid_latitude(self, db_session, address, latitude):
|
||||
"""Insert an instance with invalid data."""
|
||||
address.latitude = latitude
|
||||
|
|
@ -73,11 +73,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='latitude_between_90_degrees',
|
||||
match="latitude_between_90_degrees",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('longitude', [-181, 181])
|
||||
@pytest.mark.parametrize("longitude", [-181, 181])
|
||||
def test_invalid_longitude(self, db_session, address, longitude):
|
||||
"""Insert an instance with invalid data."""
|
||||
address.longitude = longitude
|
||||
|
|
@ -85,26 +85,26 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='longitude_between_180_degrees',
|
||||
match="longitude_between_180_degrees",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('zip_code', [-1, 0, 9999, 100000])
|
||||
@pytest.mark.parametrize("zip_code", [-1, 0, 9999, 100000])
|
||||
def test_invalid_zip_code(self, db_session, address, zip_code):
|
||||
"""Insert an instance with invalid data."""
|
||||
address.zip_code = zip_code
|
||||
db_session.add(address)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='valid_zip_code'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="valid_zip_code"):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('floor', [-1, 41])
|
||||
@pytest.mark.parametrize("floor", [-1, 41])
|
||||
def test_invalid_floor(self, db_session, address, floor):
|
||||
"""Insert an instance with invalid data."""
|
||||
address.floor = floor
|
||||
db_session.add(address)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='realistic_floor'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="realistic_floor"):
|
||||
db_session.commit()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_addresses_addresses_to_addresses_via_first_address', # shortened
|
||||
match="fk_addresses_addresses_to_addresses_via_first_address", # shortened
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_addresses_addresses_to_addresses_via_second_address', # shortened
|
||||
match="fk_addresses_addresses_to_addresses_via_second_address", # shortened
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_addresses_addresses_to_addresses_via_first_address', # shortened
|
||||
match="fk_addresses_addresses_to_addresses_via_first_address", # shortened
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ class TestConstraints:
|
|||
air_distance=path.air_distance,
|
||||
)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='duplicate key value'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="duplicate key value"):
|
||||
db_session.execute(stmt)
|
||||
|
||||
def test_symmetric_addresses(self, db_session, path):
|
||||
|
|
@ -147,7 +147,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ck_addresses_addresses_on_distances_are_symmetric_for_bicycles',
|
||||
match="ck_addresses_addresses_on_distances_are_symmetric_for_bicycles",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ class TestConstraints:
|
|||
path.air_distance = -1
|
||||
db_session.add(path)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='realistic_air_distance'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="realistic_air_distance"):
|
||||
db_session.commit()
|
||||
|
||||
def test_air_distance_too_large(self, db_session, path):
|
||||
|
|
@ -165,7 +165,7 @@ class TestConstraints:
|
|||
path.bicycle_distance = 21_000
|
||||
db_session.add(path)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='realistic_air_distance'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="realistic_air_distance"):
|
||||
db_session.commit()
|
||||
|
||||
def test_bicycle_distance_too_large(self, db_session, path):
|
||||
|
|
@ -173,7 +173,7 @@ class TestConstraints:
|
|||
path.bicycle_distance = 25_000
|
||||
db_session.add(path)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='realistic_bicycle_distance'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="realistic_bicycle_distance"):
|
||||
db_session.commit()
|
||||
|
||||
def test_air_distance_shorter_than_bicycle_distance(self, db_session, path):
|
||||
|
|
@ -181,10 +181,10 @@ class TestConstraints:
|
|||
path.bicycle_distance = round(0.75 * path.air_distance)
|
||||
db_session.add(path)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='air_distance_is_shortest'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="air_distance_is_shortest"):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('duration', [-1, 3601])
|
||||
@pytest.mark.parametrize("duration", [-1, 3601])
|
||||
def test_unrealistic_bicycle_travel_time(self, db_session, path, duration):
|
||||
"""Insert an instance with invalid data."""
|
||||
path.bicycle_duration = duration
|
||||
|
|
@ -192,7 +192,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='realistic_bicycle_travel_time',
|
||||
match="realistic_bicycle_travel_time",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ class TestFromAddresses:
|
|||
"""
|
||||
db_session.add(address)
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_make_path_instance(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -228,7 +228,7 @@ class TestFromAddresses:
|
|||
|
||||
assert db_session.query(db.Path).count() == 1
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_make_the_same_path_instance_twice(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -246,14 +246,14 @@ class TestFromAddresses:
|
|||
|
||||
assert db_session.query(db.Path).count() == 1
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_structure_of_return_value(self, db_session, address, another_address):
|
||||
"""Test instantiation of a new `Path` instance."""
|
||||
results = db.Path.from_addresses(address, another_address)
|
||||
|
||||
assert isinstance(results, list)
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_instances_must_have_air_distance(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -267,7 +267,7 @@ class TestFromAddresses:
|
|||
|
||||
assert result.air_distance is not None
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_do_not_sync_instances_with_google_maps(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -282,7 +282,7 @@ class TestFromAddresses:
|
|||
assert result.bicycle_distance is None
|
||||
assert result.bicycle_duration is None
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_sync_instances_with_google_maps(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -296,7 +296,7 @@ class TestFromAddresses:
|
|||
self.bicycle_distance = 1.25 * self.air_distance
|
||||
self.bicycle_duration = 300
|
||||
|
||||
monkeypatch.setattr(db.Path, 'sync_with_google_maps', sync)
|
||||
monkeypatch.setattr(db.Path, "sync_with_google_maps", sync)
|
||||
|
||||
paths = db.Path.from_addresses(address, another_address, google_maps=True)
|
||||
|
||||
|
|
@ -305,21 +305,21 @@ class TestFromAddresses:
|
|||
assert result.bicycle_distance is not None
|
||||
assert result.bicycle_duration is not None
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_one_path_for_two_addresses(self, db_session, address, another_address):
|
||||
"""Test instantiation of a new `Path` instance."""
|
||||
result = len(db.Path.from_addresses(address, another_address))
|
||||
|
||||
assert result == 1
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_two_paths_for_three_addresses(self, db_session, make_address):
|
||||
"""Test instantiation of a new `Path` instance."""
|
||||
result = len(db.Path.from_addresses(*[make_address() for _ in range(3)]))
|
||||
|
||||
assert result == 3
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_six_paths_for_four_addresses(self, db_session, make_address):
|
||||
"""Test instantiation of a new `Path` instance."""
|
||||
result = len(db.Path.from_addresses(*[make_address() for _ in range(4)]))
|
||||
|
|
@ -328,7 +328,7 @@ class TestFromAddresses:
|
|||
|
||||
# Tests for the `Path.from_order()` convenience method.
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_make_path_instance_from_order(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -341,7 +341,7 @@ class TestFromAddresses:
|
|||
|
||||
assert db_session.query(db.Path).count() == 1
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_make_the_same_path_instance_from_order_twice(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -358,14 +358,14 @@ class TestFromAddresses:
|
|||
|
||||
assert db_session.query(db.Path).count() == 1
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_structure_of_return_value_from_order(self, db_session, order):
|
||||
"""Test instantiation of a new `Path` instance."""
|
||||
result = db.Path.from_order(order)
|
||||
|
||||
assert isinstance(result, db.Path)
|
||||
|
||||
@pytest.mark.usefixtures('_prepare_db')
|
||||
@pytest.mark.usefixtures("_prepare_db")
|
||||
def test_sync_instance_from_order_with_google_maps(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -378,7 +378,7 @@ class TestFromAddresses:
|
|||
self.bicycle_distance = 1.25 * self.air_distance
|
||||
self.bicycle_duration = 300
|
||||
|
||||
monkeypatch.setattr(db.Path, 'sync_with_google_maps', sync)
|
||||
monkeypatch.setattr(db.Path, "sync_with_google_maps", sync)
|
||||
|
||||
result = db.Path.from_order(order, google_maps=True)
|
||||
|
||||
|
|
@ -395,251 +395,251 @@ class TestSyncWithGoogleMaps:
|
|||
"""A typical (shortened) response by the Google Maps Directions API."""
|
||||
return [
|
||||
{
|
||||
'bounds': {
|
||||
'northeast': {'lat': 44.8554284, 'lng': -0.5652398},
|
||||
'southwest': {'lat': 44.8342256, 'lng': -0.5708206},
|
||||
"bounds": {
|
||||
"northeast": {"lat": 44.8554284, "lng": -0.5652398},
|
||||
"southwest": {"lat": 44.8342256, "lng": -0.5708206},
|
||||
},
|
||||
'copyrights': 'Map data ©2021',
|
||||
'legs': [
|
||||
"copyrights": "Map data ©2021",
|
||||
"legs": [
|
||||
{
|
||||
# We choose an artificially high distance of `9999`
|
||||
# so that the synced bicycle distance is longer than
|
||||
# the randomized air distance (i.e., fake data) for sure.
|
||||
'distance': {'text': '3.0 km', 'value': 9999},
|
||||
'duration': {'text': '10 mins', 'value': 596},
|
||||
'end_address': '13 Place Paul et Jean Paul Avisseau, ...',
|
||||
'end_location': {'lat': 44.85540839999999, 'lng': -0.5672105},
|
||||
'start_address': '59 Rue Saint-François, 33000 Bordeaux, ...',
|
||||
'start_location': {'lat': 44.8342256, 'lng': -0.570372},
|
||||
'steps': [
|
||||
"distance": {"text": "3.0 km", "value": 9999},
|
||||
"duration": {"text": "10 mins", "value": 596},
|
||||
"end_address": "13 Place Paul et Jean Paul Avisseau, ...",
|
||||
"end_location": {"lat": 44.85540839999999, "lng": -0.5672105},
|
||||
"start_address": "59 Rue Saint-François, 33000 Bordeaux, ...",
|
||||
"start_location": {"lat": 44.8342256, "lng": -0.570372},
|
||||
"steps": [
|
||||
{
|
||||
'distance': {'text': '0.1 km', 'value': 138},
|
||||
'duration': {'text': '1 min', 'value': 43},
|
||||
'end_location': {
|
||||
'lat': 44.83434380000001,
|
||||
'lng': -0.5690105999999999,
|
||||
"distance": {"text": "0.1 km", "value": 138},
|
||||
"duration": {"text": "1 min", "value": 43},
|
||||
"end_location": {
|
||||
"lat": 44.83434380000001,
|
||||
"lng": -0.5690105999999999,
|
||||
},
|
||||
'html_instructions': 'Head <b>east</b> on <b> ...',
|
||||
'polyline': {'points': '}tspGxknBKcDIkB'},
|
||||
'start_location': {'lat': 44.8342256, 'lng': -0.57032},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"html_instructions": "Head <b>east</b> on <b> ...",
|
||||
"polyline": {"points": "}tspGxknBKcDIkB"},
|
||||
"start_location": {"lat": 44.8342256, "lng": -0.57032},
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '0.1 km', 'value': 115},
|
||||
'duration': {'text': '1 min', 'value': 22},
|
||||
'end_location': {'lat': 44.8353651, 'lng': -0.569199},
|
||||
'html_instructions': 'Turn <b>left</b> onto <b> ...',
|
||||
'maneuver': 'turn-left',
|
||||
'polyline': {'points': 'suspGhcnBc@JE@_@DiAHA?w@F'},
|
||||
'start_location': {
|
||||
'lat': 44.83434380000001,
|
||||
'lng': -0.5690105999999999,
|
||||
"distance": {"text": "0.1 km", "value": 115},
|
||||
"duration": {"text": "1 min", "value": 22},
|
||||
"end_location": {"lat": 44.8353651, "lng": -0.569199},
|
||||
"html_instructions": "Turn <b>left</b> onto <b> ...",
|
||||
"maneuver": "turn-left",
|
||||
"polyline": {"points": "suspGhcnBc@JE@_@DiAHA?w@F"},
|
||||
"start_location": {
|
||||
"lat": 44.83434380000001,
|
||||
"lng": -0.5690105999999999,
|
||||
},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '0.3 km', 'value': 268},
|
||||
'duration': {'text': '1 min', 'value': 59},
|
||||
'end_location': {'lat': 44.8362675, 'lng': -0.5660914},
|
||||
'html_instructions': 'Turn <b>right</b> onto <b> ...',
|
||||
'maneuver': 'turn-right',
|
||||
'polyline': {
|
||||
'points': 'a|spGndnBEYEQKi@Mi@Is@CYCOE]CQIq@ ...',
|
||||
"distance": {"text": "0.3 km", "value": 268},
|
||||
"duration": {"text": "1 min", "value": 59},
|
||||
"end_location": {"lat": 44.8362675, "lng": -0.5660914},
|
||||
"html_instructions": "Turn <b>right</b> onto <b> ...",
|
||||
"maneuver": "turn-right",
|
||||
"polyline": {
|
||||
"points": "a|spGndnBEYEQKi@Mi@Is@CYCOE]CQIq@ ...",
|
||||
},
|
||||
'start_location': {'lat': 44.8353651, 'lng': -0.56919},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"start_location": {"lat": 44.8353651, "lng": -0.56919},
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '0.1 km', 'value': 95},
|
||||
'duration': {'text': '1 min', 'value': 29},
|
||||
'end_location': {'lat': 44.8368458, 'lng': -0.5652398},
|
||||
'html_instructions': 'Slight <b>left</b> onto <b> ...',
|
||||
'maneuver': 'turn-slight-left',
|
||||
'polyline': {
|
||||
'points': 'uatpG`qmBg@aAGM?ACE[k@CICGACEGCCAAEAG?',
|
||||
"distance": {"text": "0.1 km", "value": 95},
|
||||
"duration": {"text": "1 min", "value": 29},
|
||||
"end_location": {"lat": 44.8368458, "lng": -0.5652398},
|
||||
"html_instructions": "Slight <b>left</b> onto <b> ...",
|
||||
"maneuver": "turn-slight-left",
|
||||
"polyline": {
|
||||
"points": "uatpG`qmBg@aAGM?ACE[k@CICGACEGCCAAEAG?",
|
||||
},
|
||||
'start_location': {
|
||||
'lat': 44.8362675,
|
||||
'lng': -0.5660914,
|
||||
"start_location": {
|
||||
"lat": 44.8362675,
|
||||
"lng": -0.5660914,
|
||||
},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '23 m', 'value': 23},
|
||||
'duration': {'text': '1 min', 'value': 4},
|
||||
'end_location': {'lat': 44.83697, 'lng': -0.5654425},
|
||||
'html_instructions': 'Slight <b>left</b> to stay ...',
|
||||
'maneuver': 'turn-slight-left',
|
||||
'polyline': {
|
||||
'points': 'ietpGvkmBA@C?CBCBEHA@AB?B?B?B?@',
|
||||
"distance": {"text": "23 m", "value": 23},
|
||||
"duration": {"text": "1 min", "value": 4},
|
||||
"end_location": {"lat": 44.83697, "lng": -0.5654425},
|
||||
"html_instructions": "Slight <b>left</b> to stay ...",
|
||||
"maneuver": "turn-slight-left",
|
||||
"polyline": {
|
||||
"points": "ietpGvkmBA@C?CBCBEHA@AB?B?B?B?@",
|
||||
},
|
||||
'start_location': {
|
||||
'lat': 44.8368458,
|
||||
'lng': -0.5652398,
|
||||
"start_location": {
|
||||
"lat": 44.8368458,
|
||||
"lng": -0.5652398,
|
||||
},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '0.2 km', 'value': 185},
|
||||
'duration': {'text': '1 min', 'value': 23},
|
||||
'end_location': {'lat': 44.8382126, 'lng': -0.5669969},
|
||||
'html_instructions': 'Take the ramp to <b>Le Lac ...',
|
||||
'polyline': {
|
||||
'points': 'aftpG~lmBY^[^sAdB]`@CDKLQRa@h@A@IZ',
|
||||
"distance": {"text": "0.2 km", "value": 185},
|
||||
"duration": {"text": "1 min", "value": 23},
|
||||
"end_location": {"lat": 44.8382126, "lng": -0.5669969},
|
||||
"html_instructions": "Take the ramp to <b>Le Lac ...",
|
||||
"polyline": {
|
||||
"points": "aftpG~lmBY^[^sAdB]`@CDKLQRa@h@A@IZ",
|
||||
},
|
||||
'start_location': {'lat': 44.83697, 'lng': -0.5654425},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"start_location": {"lat": 44.83697, "lng": -0.5654425},
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '0.3 km', 'value': 253},
|
||||
'duration': {'text': '1 min', 'value': 43},
|
||||
'end_location': {'lat': 44.840163, 'lng': -0.5686525},
|
||||
'html_instructions': 'Merge onto <b>Quai Richelieu</b>',
|
||||
'maneuver': 'merge',
|
||||
'polyline': {
|
||||
'points': 'ymtpGvvmBeAbAe@b@_@ZUN[To@f@e@^A?g ...',
|
||||
"distance": {"text": "0.3 km", "value": 253},
|
||||
"duration": {"text": "1 min", "value": 43},
|
||||
"end_location": {"lat": 44.840163, "lng": -0.5686525},
|
||||
"html_instructions": "Merge onto <b>Quai Richelieu</b>",
|
||||
"maneuver": "merge",
|
||||
"polyline": {
|
||||
"points": "ymtpGvvmBeAbAe@b@_@ZUN[To@f@e@^A?g ...",
|
||||
},
|
||||
'start_location': {
|
||||
'lat': 44.8382126,
|
||||
'lng': -0.5669969,
|
||||
"start_location": {
|
||||
"lat": 44.8382126,
|
||||
"lng": -0.5669969,
|
||||
},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '0.1 km', 'value': 110},
|
||||
'duration': {'text': '1 min', 'value': 21},
|
||||
'end_location': {'lat': 44.841079, 'lng': -0.5691835},
|
||||
'html_instructions': 'Continue onto <b>Quai de la ...',
|
||||
'polyline': {'points': '_ztpG`anBUNQLULUJOHMFKDWN'},
|
||||
'start_location': {'lat': 44.840163, 'lng': -0.56865},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"distance": {"text": "0.1 km", "value": 110},
|
||||
"duration": {"text": "1 min", "value": 21},
|
||||
"end_location": {"lat": 44.841079, "lng": -0.5691835},
|
||||
"html_instructions": "Continue onto <b>Quai de la ...",
|
||||
"polyline": {"points": "_ztpG`anBUNQLULUJOHMFKDWN"},
|
||||
"start_location": {"lat": 44.840163, "lng": -0.56865},
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '0.3 km', 'value': 262},
|
||||
'duration': {'text': '1 min', 'value': 44},
|
||||
'end_location': {'lat': 44.8433375, 'lng': -0.5701161},
|
||||
'html_instructions': 'Continue onto <b>Quai du ...',
|
||||
'polyline': {
|
||||
'points': 'w_upGjdnBeBl@sBn@gA^[JIBc@Nk@Nk@L',
|
||||
"distance": {"text": "0.3 km", "value": 262},
|
||||
"duration": {"text": "1 min", "value": 44},
|
||||
"end_location": {"lat": 44.8433375, "lng": -0.5701161},
|
||||
"html_instructions": "Continue onto <b>Quai du ...",
|
||||
"polyline": {
|
||||
"points": "w_upGjdnBeBl@sBn@gA^[JIBc@Nk@Nk@L",
|
||||
},
|
||||
'start_location': {'lat': 44.841079, 'lng': -0.56915},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"start_location": {"lat": 44.841079, "lng": -0.56915},
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '0.6 km', 'value': 550},
|
||||
'duration': {'text': '2 mins', 'value': 97},
|
||||
'end_location': {
|
||||
'lat': 44.84822339999999,
|
||||
'lng': -0.5705307,
|
||||
"distance": {"text": "0.6 km", "value": 550},
|
||||
"duration": {"text": "2 mins", "value": 97},
|
||||
"end_location": {
|
||||
"lat": 44.84822339999999,
|
||||
"lng": -0.5705307,
|
||||
},
|
||||
'html_instructions': 'Continue onto <b>Quai ...',
|
||||
'polyline': {
|
||||
'points': '{mupGfjnBYFI@IBaAPUD{AX}@NK@]Fe@H ...',
|
||||
"html_instructions": "Continue onto <b>Quai ...",
|
||||
"polyline": {
|
||||
"points": "{mupGfjnBYFI@IBaAPUD{AX}@NK@]Fe@H ...",
|
||||
},
|
||||
'start_location': {
|
||||
'lat': 44.8433375,
|
||||
'lng': -0.5701161,
|
||||
"start_location": {
|
||||
"lat": 44.8433375,
|
||||
"lng": -0.5701161,
|
||||
},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '0.5 km', 'value': 508},
|
||||
'duration': {'text': '1 min', 'value': 87},
|
||||
'end_location': {'lat': 44.8523224, 'lng': -0.5678223},
|
||||
'html_instructions': 'Continue onto ...',
|
||||
'polyline': {
|
||||
'points': 'klvpGxlnBWEUGWGSGMEOEOE[KMEQGIA] ...',
|
||||
"distance": {"text": "0.5 km", "value": 508},
|
||||
"duration": {"text": "1 min", "value": 87},
|
||||
"end_location": {"lat": 44.8523224, "lng": -0.5678223},
|
||||
"html_instructions": "Continue onto ...",
|
||||
"polyline": {
|
||||
"points": "klvpGxlnBWEUGWGSGMEOEOE[KMEQGIA] ...",
|
||||
},
|
||||
'start_location': {
|
||||
'lat': 44.84822339999999,
|
||||
'lng': -0.5705307,
|
||||
"start_location": {
|
||||
"lat": 44.84822339999999,
|
||||
"lng": -0.5705307,
|
||||
},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '28 m', 'value': 28},
|
||||
'duration': {'text': '1 min', 'value': 45},
|
||||
'end_location': {
|
||||
'lat': 44.85245620000001,
|
||||
'lng': -0.5681259,
|
||||
"distance": {"text": "28 m", "value": 28},
|
||||
"duration": {"text": "1 min", "value": 45},
|
||||
"end_location": {
|
||||
"lat": 44.85245620000001,
|
||||
"lng": -0.5681259,
|
||||
},
|
||||
'html_instructions': 'Turn <b>left</b> onto <b> ...',
|
||||
'maneuver': 'turn-left',
|
||||
'polyline': {'points': '_fwpGz{mBGLADGPCFEN'},
|
||||
'start_location': {
|
||||
'lat': 44.8523224,
|
||||
'lng': -0.5678223,
|
||||
"html_instructions": "Turn <b>left</b> onto <b> ...",
|
||||
"maneuver": "turn-left",
|
||||
"polyline": {"points": "_fwpGz{mBGLADGPCFEN"},
|
||||
"start_location": {
|
||||
"lat": 44.8523224,
|
||||
"lng": -0.5678223,
|
||||
},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '0.2 km', 'value': 176},
|
||||
'duration': {'text': '1 min', 'value': 31},
|
||||
'end_location': {'lat': 44.8536857, 'lng': -0.5667282},
|
||||
'html_instructions': 'Turn <b>right</b> onto <b> ...',
|
||||
'maneuver': 'turn-right',
|
||||
'polyline': {
|
||||
'points': '{fwpGx}mB_@c@mAuAOQi@m@m@y@_@c@',
|
||||
"distance": {"text": "0.2 km", "value": 176},
|
||||
"duration": {"text": "1 min", "value": 31},
|
||||
"end_location": {"lat": 44.8536857, "lng": -0.5667282},
|
||||
"html_instructions": "Turn <b>right</b> onto <b> ...",
|
||||
"maneuver": "turn-right",
|
||||
"polyline": {
|
||||
"points": "{fwpGx}mB_@c@mAuAOQi@m@m@y@_@c@",
|
||||
},
|
||||
'start_location': {
|
||||
'lat': 44.85245620000001,
|
||||
'lng': -0.5681259,
|
||||
"start_location": {
|
||||
"lat": 44.85245620000001,
|
||||
"lng": -0.5681259,
|
||||
},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '0.2 km', 'value': 172},
|
||||
'duration': {'text': '1 min', 'value': 28},
|
||||
'end_location': {'lat': 44.8547766, 'lng': -0.5682825},
|
||||
'html_instructions': 'Turn <b>left</b> onto <b> ... ',
|
||||
'maneuver': 'turn-left',
|
||||
'polyline': {'points': 'qnwpG`umBW`@UkDtF'},
|
||||
'start_location': {
|
||||
'lat': 44.8536857,
|
||||
'lng': -0.5667282,
|
||||
"distance": {"text": "0.2 km", "value": 172},
|
||||
"duration": {"text": "1 min", "value": 28},
|
||||
"end_location": {"lat": 44.8547766, "lng": -0.5682825},
|
||||
"html_instructions": "Turn <b>left</b> onto <b> ... ",
|
||||
"maneuver": "turn-left",
|
||||
"polyline": {"points": "qnwpG`umBW`@UkDtF"},
|
||||
"start_location": {
|
||||
"lat": 44.8536857,
|
||||
"lng": -0.5667282,
|
||||
},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '0.1 km', 'value': 101},
|
||||
'duration': {'text': '1 min', 'value': 17},
|
||||
'end_location': {'lat': 44.8554284, 'lng': -0.5673822},
|
||||
'html_instructions': 'Turn <b>right</b> onto ...',
|
||||
'maneuver': 'turn-right',
|
||||
'polyline': {'points': 'kuwpGv~mBa@q@cA_B[a@'},
|
||||
'start_location': {
|
||||
'lat': 44.8547766,
|
||||
'lng': -0.5682825,
|
||||
"distance": {"text": "0.1 km", "value": 101},
|
||||
"duration": {"text": "1 min", "value": 17},
|
||||
"end_location": {"lat": 44.8554284, "lng": -0.5673822},
|
||||
"html_instructions": "Turn <b>right</b> onto ...",
|
||||
"maneuver": "turn-right",
|
||||
"polyline": {"points": "kuwpGv~mBa@q@cA_B[a@"},
|
||||
"start_location": {
|
||||
"lat": 44.8547766,
|
||||
"lng": -0.5682825,
|
||||
},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
{
|
||||
'distance': {'text': '15 m', 'value': 15},
|
||||
'duration': {'text': '1 min', 'value': 3},
|
||||
'end_location': {
|
||||
'lat': 44.85540839999999,
|
||||
'lng': -0.5672105,
|
||||
"distance": {"text": "15 m", "value": 15},
|
||||
"duration": {"text": "1 min", "value": 3},
|
||||
"end_location": {
|
||||
"lat": 44.85540839999999,
|
||||
"lng": -0.5672105,
|
||||
},
|
||||
'html_instructions': 'Turn <b>right</b> onto <b> ...',
|
||||
'maneuver': 'turn-right',
|
||||
'polyline': {'points': 'mywpGbymBBC@C?E?C?E?EAC'},
|
||||
'start_location': {
|
||||
'lat': 44.8554284,
|
||||
'lng': -0.5673822,
|
||||
"html_instructions": "Turn <b>right</b> onto <b> ...",
|
||||
"maneuver": "turn-right",
|
||||
"polyline": {"points": "mywpGbymBBC@C?E?C?E?EAC"},
|
||||
"start_location": {
|
||||
"lat": 44.8554284,
|
||||
"lng": -0.5673822,
|
||||
},
|
||||
'travel_mode': 'BICYCLING',
|
||||
"travel_mode": "BICYCLING",
|
||||
},
|
||||
],
|
||||
'traffic_speed_entry': [],
|
||||
'via_waypoint': [],
|
||||
"traffic_speed_entry": [],
|
||||
"via_waypoint": [],
|
||||
},
|
||||
],
|
||||
'overview_polyline': {
|
||||
'points': '}tspGxknBUoGi@LcDVe@_CW{Ba@sC[eA_@} ...',
|
||||
"overview_polyline": {
|
||||
"points": "}tspGxknBUoGi@LcDVe@_CW{Ba@sC[eA_@} ...",
|
||||
},
|
||||
'summary': 'Quai des Chartrons',
|
||||
'warnings': ['Bicycling directions are in beta ...'],
|
||||
'waypoint_order': [],
|
||||
"summary": "Quai des Chartrons",
|
||||
"warnings": ["Bicycling directions are in beta ..."],
|
||||
"waypoint_order": [],
|
||||
},
|
||||
]
|
||||
|
||||
|
|
@ -650,9 +650,9 @@ class TestSyncWithGoogleMaps:
|
|||
def directions(_self, *_args, **_kwargs):
|
||||
return api_response
|
||||
|
||||
monkeypatch.setattr(googlemaps.Client, 'directions', directions)
|
||||
monkeypatch.setattr(googlemaps.Client, "directions", directions)
|
||||
|
||||
@pytest.mark.usefixtures('_fake_google_api')
|
||||
@pytest.mark.usefixtures("_fake_google_api")
|
||||
def test_sync_instances_with_google_maps(self, db_session, path):
|
||||
"""Call the method for a `Path` object without Google data."""
|
||||
path.bicycle_distance = None
|
||||
|
|
@ -665,7 +665,7 @@ class TestSyncWithGoogleMaps:
|
|||
assert path.bicycle_duration == 596
|
||||
assert path._directions is not None
|
||||
|
||||
@pytest.mark.usefixtures('_fake_google_api')
|
||||
@pytest.mark.usefixtures("_fake_google_api")
|
||||
def test_repeated_sync_instances_with_google_maps(self, db_session, path):
|
||||
"""Call the method for a `Path` object with Google data.
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_addresses_pixels_to_addresses_via_address_id_city_id',
|
||||
match="fk_addresses_pixels_to_addresses_via_address_id_city_id",
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_addresses_pixels_to_addresses_via_address_id_city_id',
|
||||
match="fk_addresses_pixels_to_addresses_via_address_id_city_id",
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_addresses_pixels_to_grids_via_grid_id_city_id',
|
||||
match="fk_addresses_pixels_to_grids_via_grid_id_city_id",
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_addresses_pixels_to_pixels_via_pixel_id_grid_id',
|
||||
match="fk_addresses_pixels_to_pixels_via_pixel_id_grid_id",
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
|
|
@ -131,5 +131,5 @@ class TestConstraints:
|
|||
|
||||
db_session.add(another_assoc)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='duplicate key value'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="duplicate key value"):
|
||||
db_session.commit()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class TestSpecialMethods:
|
|||
"""`City` has a non-literal text representation."""
|
||||
result = repr(city)
|
||||
|
||||
assert result == f'<City({city.name})>'
|
||||
assert result == f"<City({city.name})>"
|
||||
|
||||
|
||||
@pytest.mark.db
|
||||
|
|
@ -43,8 +43,8 @@ class TestProperties:
|
|||
result = city.center
|
||||
|
||||
assert isinstance(result, utils.Location)
|
||||
assert result.latitude == pytest.approx(city_data['center_latitude'])
|
||||
assert result.longitude == pytest.approx(city_data['center_longitude'])
|
||||
assert result.latitude == pytest.approx(city_data["center_latitude"])
|
||||
assert result.longitude == pytest.approx(city_data["center_longitude"])
|
||||
|
||||
def test_center_is_cached(self, city):
|
||||
"""Test `City.center` property."""
|
||||
|
|
@ -58,8 +58,8 @@ class TestProperties:
|
|||
result = city.northeast
|
||||
|
||||
assert isinstance(result, utils.Location)
|
||||
assert result.latitude == pytest.approx(city_data['northeast_latitude'])
|
||||
assert result.longitude == pytest.approx(city_data['northeast_longitude'])
|
||||
assert result.latitude == pytest.approx(city_data["northeast_latitude"])
|
||||
assert result.longitude == pytest.approx(city_data["northeast_longitude"])
|
||||
|
||||
def test_northeast_is_cached(self, city):
|
||||
"""Test `City.northeast` property."""
|
||||
|
|
@ -73,8 +73,8 @@ class TestProperties:
|
|||
result = city.southwest
|
||||
|
||||
assert isinstance(result, utils.Location)
|
||||
assert result.latitude == pytest.approx(city_data['southwest_latitude'])
|
||||
assert result.longitude == pytest.approx(city_data['southwest_longitude'])
|
||||
assert result.latitude == pytest.approx(city_data["southwest_latitude"])
|
||||
assert result.longitude == pytest.approx(city_data["southwest_longitude"])
|
||||
|
||||
def test_southwest_is_cached(self, city):
|
||||
"""Test `City.southwest` property."""
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class TestSpecialMethods:
|
|||
"""`Courier` has a non-literal text representation."""
|
||||
result = repr(courier)
|
||||
|
||||
assert result == f'<Courier(#{courier.id})>'
|
||||
assert result == f"<Courier(#{courier.id})>"
|
||||
|
||||
|
||||
@pytest.mark.db
|
||||
|
|
@ -36,10 +36,10 @@ class TestConstraints:
|
|||
|
||||
def test_invalid_vehicle(self, db_session, courier):
|
||||
"""Insert an instance with invalid data."""
|
||||
courier.vehicle = 'invalid'
|
||||
courier.vehicle = "invalid"
|
||||
db_session.add(courier)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='available_vehicle_types'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="available_vehicle_types"):
|
||||
db_session.commit()
|
||||
|
||||
def test_negative_speed(self, db_session, courier):
|
||||
|
|
@ -47,7 +47,7 @@ class TestConstraints:
|
|||
courier.historic_speed = -1
|
||||
db_session.add(courier)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='realistic_speed'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="realistic_speed"):
|
||||
db_session.commit()
|
||||
|
||||
def test_unrealistic_speed(self, db_session, courier):
|
||||
|
|
@ -55,7 +55,7 @@ class TestConstraints:
|
|||
courier.historic_speed = 999
|
||||
db_session.add(courier)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='realistic_speed'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="realistic_speed"):
|
||||
db_session.commit()
|
||||
|
||||
def test_negative_capacity(self, db_session, courier):
|
||||
|
|
@ -63,7 +63,7 @@ class TestConstraints:
|
|||
courier.capacity = -1
|
||||
db_session.add(courier)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='capacity_under_200_liters'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="capacity_under_200_liters"):
|
||||
db_session.commit()
|
||||
|
||||
def test_too_much_capacity(self, db_session, courier):
|
||||
|
|
@ -71,7 +71,7 @@ class TestConstraints:
|
|||
courier.capacity = 999
|
||||
db_session.add(courier)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='capacity_under_200_liters'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="capacity_under_200_liters"):
|
||||
db_session.commit()
|
||||
|
||||
def test_negative_pay_per_hour(self, db_session, courier):
|
||||
|
|
@ -79,7 +79,7 @@ class TestConstraints:
|
|||
courier.pay_per_hour = -1
|
||||
db_session.add(courier)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='realistic_pay_per_hour'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="realistic_pay_per_hour"):
|
||||
db_session.commit()
|
||||
|
||||
def test_too_much_pay_per_hour(self, db_session, courier):
|
||||
|
|
@ -87,7 +87,7 @@ class TestConstraints:
|
|||
courier.pay_per_hour = 9999
|
||||
db_session.add(courier)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='realistic_pay_per_hour'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="realistic_pay_per_hour"):
|
||||
db_session.commit()
|
||||
|
||||
def test_negative_pay_per_order(self, db_session, courier):
|
||||
|
|
@ -95,7 +95,7 @@ class TestConstraints:
|
|||
courier.pay_per_order = -1
|
||||
db_session.add(courier)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='realistic_pay_per_order'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="realistic_pay_per_order"):
|
||||
db_session.commit()
|
||||
|
||||
def test_too_much_pay_per_order(self, db_session, courier):
|
||||
|
|
@ -103,5 +103,5 @@ class TestConstraints:
|
|||
courier.pay_per_order = 999
|
||||
db_session.add(courier)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='realistic_pay_per_order'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="realistic_pay_per_order"):
|
||||
db_session.commit()
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class TestSpecialMethods:
|
|||
"""`Customer` has a non-literal text representation."""
|
||||
result = repr(customer)
|
||||
|
||||
assert result == f'<Customer(#{customer.id})>'
|
||||
assert result == f"<Customer(#{customer.id})>"
|
||||
|
||||
|
||||
@pytest.mark.db
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from tests import config as test_config
|
|||
from velofy import db
|
||||
|
||||
|
||||
MODEL = 'hets'
|
||||
MODEL = "hets"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
@ -52,7 +52,7 @@ class TestSpecialMethods:
|
|||
|
||||
assert (
|
||||
result
|
||||
== f'<Forecast: {forecast.prediction} for pixel ({forecast.pixel.n_x}|{forecast.pixel.n_y}) at {forecast.start_at}>' # noqa:E501
|
||||
== f"<Forecast: {forecast.prediction} for pixel ({forecast.pixel.n_x}|{forecast.pixel.n_y}) at {forecast.start_at}>" # noqa:E501
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -80,11 +80,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_forecasts_to_pixels_via_pixel_id',
|
||||
match="fk_forecasts_to_pixels_via_pixel_id",
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
@pytest.mark.parametrize('hour', [10, 23])
|
||||
@pytest.mark.parametrize("hour", [10, 23])
|
||||
def test_invalid_start_at_outside_operating_hours(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -102,7 +102,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='within_operating_hours',
|
||||
match="within_operating_hours",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='must_be_quarters_of_the_hour',
|
||||
match="must_be_quarters_of_the_hour",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='no_seconds',
|
||||
match="no_seconds",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -135,11 +135,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='no_microseconds',
|
||||
match="no_microseconds",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('value', [-1, 0])
|
||||
@pytest.mark.parametrize("value", [-1, 0])
|
||||
def test_positive_time_step(self, db_session, forecast, value):
|
||||
"""Insert an instance with invalid data."""
|
||||
forecast.time_step = value
|
||||
|
|
@ -147,11 +147,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='time_step_must_be_positive',
|
||||
match="time_step_must_be_positive",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('value', [-1, 0])
|
||||
@pytest.mark.parametrize("value", [-1, 0])
|
||||
def test_positive_train_horizon(self, db_session, forecast, value):
|
||||
"""Insert an instance with invalid data."""
|
||||
forecast.train_horizon = value
|
||||
|
|
@ -159,7 +159,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='training_horizon_must_be_positive',
|
||||
match="training_horizon_must_be_positive",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='actuals_must_be_non_negative',
|
||||
match="actuals_must_be_non_negative",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ci_upper_and_lower_bounds',
|
||||
match="ci_upper_and_lower_bounds",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -209,7 +209,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ci_upper_and_lower_bounds',
|
||||
match="ci_upper_and_lower_bounds",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ci_upper_and_lower_bounds',
|
||||
match="ci_upper_and_lower_bounds",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -235,7 +235,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ci_upper_and_lower_bounds',
|
||||
match="ci_upper_and_lower_bounds",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -249,7 +249,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='prediction_must_be_within_ci',
|
||||
match="prediction_must_be_within_ci",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='prediction_must_be_within_ci',
|
||||
match="prediction_must_be_within_ci",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -281,7 +281,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='prediction_must_be_within_ci',
|
||||
match="prediction_must_be_within_ci",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='prediction_must_be_within_ci',
|
||||
match="prediction_must_be_within_ci",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -313,7 +313,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='prediction_must_be_within_ci',
|
||||
match="prediction_must_be_within_ci",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -331,7 +331,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='prediction_must_be_within_ci',
|
||||
match="prediction_must_be_within_ci",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -345,7 +345,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='prediction_must_be_within_ci',
|
||||
match="prediction_must_be_within_ci",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -363,7 +363,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='prediction_must_be_within_ci',
|
||||
match="prediction_must_be_within_ci",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -385,7 +385,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ci_upper_bound_greater_than_lower_bound',
|
||||
match="ci_upper_bound_greater_than_lower_bound",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -407,7 +407,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ci_upper_bound_greater_than_lower_bound',
|
||||
match="ci_upper_bound_greater_than_lower_bound",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -422,7 +422,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ci95_must_be_wider_than_ci80',
|
||||
match="ci95_must_be_wider_than_ci80",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -440,7 +440,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ci95_must_be_wider_than_ci80',
|
||||
match="ci95_must_be_wider_than_ci80",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -464,7 +464,7 @@ class TestConstraints:
|
|||
)
|
||||
db_session.add(another_forecast)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='duplicate key value'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="duplicate key value"):
|
||||
db_session.commit()
|
||||
|
||||
|
||||
|
|
@ -495,16 +495,16 @@ class TestFromDataFrameConstructor:
|
|||
noon_start_at + dt.timedelta(minutes=test_config.LONG_TIME_STEP),
|
||||
],
|
||||
)
|
||||
index.name = 'start_at'
|
||||
index.name = "start_at"
|
||||
|
||||
return pd.DataFrame(
|
||||
data={
|
||||
'actual': (11, 12, 13),
|
||||
'prediction': (11.3, 12.3, 13.3),
|
||||
'low80': (1.123, 1.23, 1.323),
|
||||
'high80': (112.34, 123.4, 132.34),
|
||||
'low95': (0.1123, 0.123, 0.1323),
|
||||
'high95': (1123.45, 1234.5, 1323.45),
|
||||
"actual": (11, 12, 13),
|
||||
"prediction": (11.3, 12.3, 13.3),
|
||||
"low80": (1.123, 1.23, 1.323),
|
||||
"high80": (112.34, 123.4, 132.34),
|
||||
"low95": (0.1123, 0.123, 0.1323),
|
||||
"high95": (1123.45, 1234.5, 1323.45),
|
||||
},
|
||||
index=index,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class TestSpecialMethods:
|
|||
"""`Grid` has a non-literal text representation."""
|
||||
result = repr(grid)
|
||||
|
||||
assert result == f'<Grid: {grid.pixel_area} sqr. km>'
|
||||
assert result == f"<Grid: {grid.pixel_area} sqr. km>"
|
||||
|
||||
|
||||
@pytest.mark.db
|
||||
|
|
@ -45,7 +45,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_grids_to_cities_via_city_id',
|
||||
match="fk_grids_to_cities_via_city_id",
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ class TestConstraints:
|
|||
another_grid = db.Grid(city=grid.city, side_length=grid.side_length)
|
||||
db_session.add(another_grid)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='duplicate key value'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="duplicate key value"):
|
||||
db_session.commit()
|
||||
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ class TestGridification:
|
|||
query = (
|
||||
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501
|
||||
)
|
||||
monkeypatch.setattr(db, 'session', mock)
|
||||
monkeypatch.setattr(db, "session", mock)
|
||||
|
||||
return query
|
||||
|
||||
|
|
@ -205,7 +205,7 @@ class TestGridification:
|
|||
|
||||
@pytest.mark.db
|
||||
@pytest.mark.no_cover
|
||||
@pytest.mark.parametrize('side_length', [250, 500, 1_000, 2_000, 4_000, 8_000])
|
||||
@pytest.mark.parametrize("side_length", [250, 500, 1_000, 2_000, 4_000, 8_000])
|
||||
def test_make_random_grids(
|
||||
self,
|
||||
db_session,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class TestSpecialMethods:
|
|||
"""`Order` has a non-literal text representation."""
|
||||
result = repr(order)
|
||||
|
||||
assert result == f'<Order(#{order.id})>'
|
||||
assert result == f"<Order(#{order.id})>"
|
||||
|
||||
|
||||
@pytest.mark.db
|
||||
|
|
@ -60,7 +60,7 @@ class TestConstraints:
|
|||
# Must delete without ORM as otherwise an UPDATE statement is emitted.
|
||||
stmt = sqla.delete(db.Customer).where(db.Customer.id == order.customer.id)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='fk_orders_to_customers'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_customers"):
|
||||
db_session.execute(stmt)
|
||||
|
||||
def test_delete_a_referenced_courier(self, db_session, order):
|
||||
|
|
@ -71,7 +71,7 @@ class TestConstraints:
|
|||
# Must delete without ORM as otherwise an UPDATE statement is emitted.
|
||||
stmt = sqla.delete(db.Courier).where(db.Courier.id == order.courier.id)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='fk_orders_to_couriers'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_couriers"):
|
||||
db_session.execute(stmt)
|
||||
|
||||
def test_delete_a_referenced_restaurant(self, db_session, order):
|
||||
|
|
@ -82,7 +82,7 @@ class TestConstraints:
|
|||
# Must delete without ORM as otherwise an UPDATE statement is emitted.
|
||||
stmt = sqla.delete(db.Restaurant).where(db.Restaurant.id == order.restaurant.id)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='fk_orders_to_restaurants'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_restaurants"):
|
||||
db_session.execute(stmt)
|
||||
|
||||
def test_change_a_referenced_pickup_address(self, db_session, order, make_address):
|
||||
|
|
@ -97,7 +97,7 @@ class TestConstraints:
|
|||
order.restaurant.address = make_address()
|
||||
db_session.add(order.restaurant.address)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='fk_orders_to_restaurants'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_restaurants"):
|
||||
db_session.commit()
|
||||
|
||||
# Here should be a test to check deletion of a referenced pickup address, so
|
||||
|
|
@ -114,7 +114,7 @@ class TestConstraints:
|
|||
# Must delete without ORM as otherwise an UPDATE statement is emitted.
|
||||
stmt = sqla.delete(db.Address).where(db.Address.id == order.delivery_address.id)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='fk_orders_to_addresses'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_addresses"):
|
||||
db_session.execute(stmt)
|
||||
|
||||
def test_ad_hoc_order_with_scheduled_delivery_at(self, db_session, order):
|
||||
|
|
@ -128,7 +128,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='either_ad_hoc_or_scheduled_order',
|
||||
match="either_ad_hoc_or_scheduled_order",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='either_ad_hoc_or_scheduled_order',
|
||||
match="either_ad_hoc_or_scheduled_order",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ad_hoc_orders_within_business_hours',
|
||||
match="ad_hoc_orders_within_business_hours",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='ad_hoc_orders_within_business_hours',
|
||||
match="ad_hoc_orders_within_business_hours",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='scheduled_orders_within_business_hours',
|
||||
match="scheduled_orders_within_business_hours",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -197,7 +197,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='scheduled_orders_within_business_hours',
|
||||
match="scheduled_orders_within_business_hours",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -229,11 +229,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='scheduled_orders_within_business_hours',
|
||||
match="scheduled_orders_within_business_hours",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('minute', [min_ for min_ in range(60) if min_ % 15 != 0])
|
||||
@pytest.mark.parametrize("minute", [min_ for min_ in range(60) if min_ % 15 != 0])
|
||||
def test_scheduled_order_at_non_quarter_of_an_hour(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -254,11 +254,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='scheduled_orders_must_be_at_quarters_of_an_hour',
|
||||
match="scheduled_orders_must_be_at_quarters_of_an_hour",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('second', list(range(1, 60)))
|
||||
@pytest.mark.parametrize("second", list(range(1, 60)))
|
||||
def test_scheduled_order_at_non_quarter_of_an_hour_by_seconds(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -280,7 +280,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='scheduled_orders_must_be_at_quarters_of_an_hour',
|
||||
match="scheduled_orders_must_be_at_quarters_of_an_hour",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -309,7 +309,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='scheduled_orders_not_within_30_minutes',
|
||||
match="scheduled_orders_not_within_30_minutes",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -326,7 +326,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='only_cancelled_orders_may_have_cancelled_at',
|
||||
match="only_cancelled_orders_may_have_cancelled_at",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -340,11 +340,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='cancelled_orders_must_not_be_delivered',
|
||||
match="cancelled_orders_must_not_be_delivered",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('duration', [-1, 2701])
|
||||
@pytest.mark.parametrize("duration", [-1, 2701])
|
||||
def test_estimated_prep_duration_out_of_range(self, db_session, order, duration):
|
||||
"""Insert an instance with invalid data."""
|
||||
order.estimated_prep_duration = duration
|
||||
|
|
@ -352,11 +352,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='between_0_and_2700',
|
||||
match="between_0_and_2700",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('duration', [1, 59, 119, 2699])
|
||||
@pytest.mark.parametrize("duration", [1, 59, 119, 2699])
|
||||
def test_estimated_prep_duration_not_whole_minute(
|
||||
self,
|
||||
db_session,
|
||||
|
|
@ -369,11 +369,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='must_be_whole_minutes',
|
||||
match="must_be_whole_minutes",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('duration', [-1, 901])
|
||||
@pytest.mark.parametrize("duration", [-1, 901])
|
||||
def test_estimated_prep_buffer_out_of_range(self, db_session, order, duration):
|
||||
"""Insert an instance with invalid data."""
|
||||
order.estimated_prep_buffer = duration
|
||||
|
|
@ -381,11 +381,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='between_0_and_900',
|
||||
match="between_0_and_900",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('duration', [1, 59, 119, 899])
|
||||
@pytest.mark.parametrize("duration", [1, 59, 119, 899])
|
||||
def test_estimated_prep_buffer_not_whole_minute(self, db_session, order, duration):
|
||||
"""Insert an instance with invalid data."""
|
||||
order.estimated_prep_buffer = duration
|
||||
|
|
@ -393,11 +393,11 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='must_be_whole_minutes',
|
||||
match="must_be_whole_minutes",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize('utilization', [-1, 101])
|
||||
@pytest.mark.parametrize("utilization", [-1, 101])
|
||||
def test_utilization_out_of_range(self, db_session, order, utilization):
|
||||
"""Insert an instance with invalid data."""
|
||||
order.utilization = utilization
|
||||
|
|
@ -405,22 +405,22 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='between_0_and_100',
|
||||
match="between_0_and_100",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'column',
|
||||
"column",
|
||||
[
|
||||
'scheduled_delivery_at',
|
||||
'cancelled_at',
|
||||
'restaurant_notified_at',
|
||||
'restaurant_confirmed_at',
|
||||
'estimated_prep_duration',
|
||||
'dispatch_at',
|
||||
'courier_notified_at',
|
||||
'courier_accepted_at',
|
||||
'left_pickup_at',
|
||||
"scheduled_delivery_at",
|
||||
"cancelled_at",
|
||||
"restaurant_notified_at",
|
||||
"restaurant_confirmed_at",
|
||||
"estimated_prep_duration",
|
||||
"dispatch_at",
|
||||
"courier_notified_at",
|
||||
"courier_accepted_at",
|
||||
"left_pickup_at",
|
||||
],
|
||||
)
|
||||
def test_unset_timestamp_column_not_marked_as_uncorrected(
|
||||
|
|
@ -438,25 +438,25 @@ class TestConstraints:
|
|||
setattr(order, column, None)
|
||||
|
||||
# Setting both the timestamp and its correction column to NULL is allowed.
|
||||
setattr(order, f'{column}_corrected', None)
|
||||
setattr(order, f"{column}_corrected", None)
|
||||
|
||||
db_session.add(order)
|
||||
db_session.commit()
|
||||
|
||||
# Also, an unset timestamp column may always be marked as corrected.
|
||||
setattr(order, f'{column}_corrected', True)
|
||||
setattr(order, f"{column}_corrected", True)
|
||||
|
||||
db_session.add(order)
|
||||
db_session.commit()
|
||||
|
||||
# Without a timestamp set, a column may not be marked as uncorrected.
|
||||
setattr(order, f'{column}_corrected', False)
|
||||
setattr(order, f"{column}_corrected", False)
|
||||
|
||||
db_session.add(order)
|
||||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='corrections_only_for_set_value',
|
||||
match="corrections_only_for_set_value",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -473,7 +473,7 @@ class TestConstraints:
|
|||
self.test_unset_timestamp_column_not_marked_as_uncorrected(
|
||||
db_session,
|
||||
order,
|
||||
'pickup_at',
|
||||
"pickup_at",
|
||||
)
|
||||
|
||||
def test_unset_timestamp_column_not_marked_as_uncorrected_special_case2(
|
||||
|
|
@ -490,21 +490,21 @@ class TestConstraints:
|
|||
self.test_unset_timestamp_column_not_marked_as_uncorrected(
|
||||
db_session,
|
||||
order,
|
||||
'delivery_at',
|
||||
"delivery_at",
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'column',
|
||||
"column",
|
||||
[
|
||||
'restaurant_notified_at',
|
||||
'restaurant_confirmed_at',
|
||||
'estimated_prep_duration',
|
||||
'dispatch_at',
|
||||
'courier_notified_at',
|
||||
'courier_accepted_at',
|
||||
'pickup_at',
|
||||
'left_pickup_at',
|
||||
'delivery_at',
|
||||
"restaurant_notified_at",
|
||||
"restaurant_confirmed_at",
|
||||
"estimated_prep_duration",
|
||||
"dispatch_at",
|
||||
"courier_notified_at",
|
||||
"courier_accepted_at",
|
||||
"pickup_at",
|
||||
"left_pickup_at",
|
||||
"delivery_at",
|
||||
],
|
||||
)
|
||||
def test_set_timestamp_column_is_not_unmarked(
|
||||
|
|
@ -523,24 +523,24 @@ class TestConstraints:
|
|||
|
||||
# A set timestamp may be marked as either corrected or uncorrected.
|
||||
|
||||
setattr(order, f'{column}_corrected', True)
|
||||
setattr(order, f"{column}_corrected", True)
|
||||
|
||||
db_session.add(order)
|
||||
db_session.commit()
|
||||
|
||||
setattr(order, f'{column}_corrected', False)
|
||||
setattr(order, f"{column}_corrected", False)
|
||||
|
||||
db_session.add(order)
|
||||
db_session.commit()
|
||||
|
||||
# A set timestamp may not be left unmarked.
|
||||
setattr(order, f'{column}_corrected', None)
|
||||
setattr(order, f"{column}_corrected", None)
|
||||
|
||||
db_session.add(order)
|
||||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='corrections_only_for_set_value',
|
||||
match="corrections_only_for_set_value",
|
||||
):
|
||||
db_session.commit()
|
||||
|
||||
|
|
@ -556,7 +556,7 @@ class TestConstraints:
|
|||
self.test_set_timestamp_column_is_not_unmarked(
|
||||
db_session,
|
||||
pre_order,
|
||||
'scheduled_delivery_at',
|
||||
"scheduled_delivery_at",
|
||||
)
|
||||
|
||||
def test_set_timestamp_column_is_not_unmarked_special_case2(
|
||||
|
|
@ -579,54 +579,54 @@ class TestConstraints:
|
|||
self.test_set_timestamp_column_is_not_unmarked(
|
||||
db_session,
|
||||
order,
|
||||
'cancelled_at',
|
||||
"cancelled_at",
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'comparison',
|
||||
"comparison",
|
||||
[
|
||||
'placed_at < first_estimated_delivery_at',
|
||||
'placed_at < restaurant_notified_at',
|
||||
'placed_at < restaurant_confirmed_at',
|
||||
'placed_at < dispatch_at',
|
||||
'placed_at < courier_notified_at',
|
||||
'placed_at < courier_accepted_at',
|
||||
'placed_at < reached_pickup_at',
|
||||
'placed_at < pickup_at',
|
||||
'placed_at < left_pickup_at',
|
||||
'placed_at < reached_delivery_at',
|
||||
'placed_at < delivery_at',
|
||||
'restaurant_notified_at < restaurant_confirmed_at',
|
||||
'restaurant_notified_at < pickup_at',
|
||||
'restaurant_confirmed_at < pickup_at',
|
||||
'dispatch_at < courier_notified_at',
|
||||
'dispatch_at < courier_accepted_at',
|
||||
'dispatch_at < reached_pickup_at',
|
||||
'dispatch_at < pickup_at',
|
||||
'dispatch_at < left_pickup_at',
|
||||
'dispatch_at < reached_delivery_at',
|
||||
'dispatch_at < delivery_at',
|
||||
'courier_notified_at < courier_accepted_at',
|
||||
'courier_notified_at < reached_pickup_at',
|
||||
'courier_notified_at < pickup_at',
|
||||
'courier_notified_at < left_pickup_at',
|
||||
'courier_notified_at < reached_delivery_at',
|
||||
'courier_notified_at < delivery_at',
|
||||
'courier_accepted_at < reached_pickup_at',
|
||||
'courier_accepted_at < pickup_at',
|
||||
'courier_accepted_at < left_pickup_at',
|
||||
'courier_accepted_at < reached_delivery_at',
|
||||
'courier_accepted_at < delivery_at',
|
||||
'reached_pickup_at < pickup_at',
|
||||
'reached_pickup_at < left_pickup_at',
|
||||
'reached_pickup_at < reached_delivery_at',
|
||||
'reached_pickup_at < delivery_at',
|
||||
'pickup_at < left_pickup_at',
|
||||
'pickup_at < reached_delivery_at',
|
||||
'pickup_at < delivery_at',
|
||||
'left_pickup_at < reached_delivery_at',
|
||||
'left_pickup_at < delivery_at',
|
||||
'reached_delivery_at < delivery_at',
|
||||
"placed_at < first_estimated_delivery_at",
|
||||
"placed_at < restaurant_notified_at",
|
||||
"placed_at < restaurant_confirmed_at",
|
||||
"placed_at < dispatch_at",
|
||||
"placed_at < courier_notified_at",
|
||||
"placed_at < courier_accepted_at",
|
||||
"placed_at < reached_pickup_at",
|
||||
"placed_at < pickup_at",
|
||||
"placed_at < left_pickup_at",
|
||||
"placed_at < reached_delivery_at",
|
||||
"placed_at < delivery_at",
|
||||
"restaurant_notified_at < restaurant_confirmed_at",
|
||||
"restaurant_notified_at < pickup_at",
|
||||
"restaurant_confirmed_at < pickup_at",
|
||||
"dispatch_at < courier_notified_at",
|
||||
"dispatch_at < courier_accepted_at",
|
||||
"dispatch_at < reached_pickup_at",
|
||||
"dispatch_at < pickup_at",
|
||||
"dispatch_at < left_pickup_at",
|
||||
"dispatch_at < reached_delivery_at",
|
||||
"dispatch_at < delivery_at",
|
||||
"courier_notified_at < courier_accepted_at",
|
||||
"courier_notified_at < reached_pickup_at",
|
||||
"courier_notified_at < pickup_at",
|
||||
"courier_notified_at < left_pickup_at",
|
||||
"courier_notified_at < reached_delivery_at",
|
||||
"courier_notified_at < delivery_at",
|
||||
"courier_accepted_at < reached_pickup_at",
|
||||
"courier_accepted_at < pickup_at",
|
||||
"courier_accepted_at < left_pickup_at",
|
||||
"courier_accepted_at < reached_delivery_at",
|
||||
"courier_accepted_at < delivery_at",
|
||||
"reached_pickup_at < pickup_at",
|
||||
"reached_pickup_at < left_pickup_at",
|
||||
"reached_pickup_at < reached_delivery_at",
|
||||
"reached_pickup_at < delivery_at",
|
||||
"pickup_at < left_pickup_at",
|
||||
"pickup_at < reached_delivery_at",
|
||||
"pickup_at < delivery_at",
|
||||
"left_pickup_at < reached_delivery_at",
|
||||
"left_pickup_at < delivery_at",
|
||||
"reached_delivery_at < delivery_at",
|
||||
],
|
||||
)
|
||||
def test_timestamps_unordered(
|
||||
|
|
@ -640,17 +640,17 @@ class TestConstraints:
|
|||
There are two special cases for this test case below,
|
||||
where other attributes on `order` must be unset.
|
||||
"""
|
||||
smaller, bigger = comparison.split(' < ')
|
||||
smaller, bigger = comparison.split(" < ")
|
||||
|
||||
assert smaller is not None
|
||||
|
||||
violating_timestamp = getattr(order, smaller) - dt.timedelta(seconds=1)
|
||||
setattr(order, bigger, violating_timestamp)
|
||||
setattr(order, f'{bigger}_corrected', False)
|
||||
setattr(order, f"{bigger}_corrected", False)
|
||||
|
||||
db_session.add(order)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='ordered_timestamps'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="ordered_timestamps"):
|
||||
db_session.commit()
|
||||
|
||||
def test_timestamps_unordered_scheduled(self, db_session, pre_order):
|
||||
|
|
@ -664,22 +664,22 @@ class TestConstraints:
|
|||
self.test_timestamps_unordered(
|
||||
db_session,
|
||||
pre_order,
|
||||
'placed_at < scheduled_delivery_at',
|
||||
"placed_at < scheduled_delivery_at",
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'comparison',
|
||||
"comparison",
|
||||
[
|
||||
'placed_at < cancelled_at',
|
||||
'restaurant_notified_at < cancelled_at',
|
||||
'restaurant_confirmed_at < cancelled_at',
|
||||
'dispatch_at < cancelled_at',
|
||||
'courier_notified_at < cancelled_at',
|
||||
'courier_accepted_at < cancelled_at',
|
||||
'reached_pickup_at < cancelled_at',
|
||||
'pickup_at < cancelled_at',
|
||||
'left_pickup_at < cancelled_at',
|
||||
'reached_delivery_at < cancelled_at',
|
||||
"placed_at < cancelled_at",
|
||||
"restaurant_notified_at < cancelled_at",
|
||||
"restaurant_confirmed_at < cancelled_at",
|
||||
"dispatch_at < cancelled_at",
|
||||
"courier_notified_at < cancelled_at",
|
||||
"courier_accepted_at < cancelled_at",
|
||||
"reached_pickup_at < cancelled_at",
|
||||
"pickup_at < cancelled_at",
|
||||
"left_pickup_at < cancelled_at",
|
||||
"reached_delivery_at < cancelled_at",
|
||||
],
|
||||
)
|
||||
def test_timestamps_unordered_cancelled(
|
||||
|
|
@ -758,23 +758,23 @@ class TestProperties:
|
|||
assert result is False
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'column',
|
||||
"column",
|
||||
[
|
||||
'scheduled_delivery_at',
|
||||
'cancelled_at',
|
||||
'restaurant_notified_at',
|
||||
'restaurant_confirmed_at',
|
||||
'dispatch_at',
|
||||
'courier_notified_at',
|
||||
'courier_accepted_at',
|
||||
'pickup_at',
|
||||
'left_pickup_at',
|
||||
'delivery_at',
|
||||
"scheduled_delivery_at",
|
||||
"cancelled_at",
|
||||
"restaurant_notified_at",
|
||||
"restaurant_confirmed_at",
|
||||
"dispatch_at",
|
||||
"courier_notified_at",
|
||||
"courier_accepted_at",
|
||||
"pickup_at",
|
||||
"left_pickup_at",
|
||||
"delivery_at",
|
||||
],
|
||||
)
|
||||
def test_is_corrected(self, order, column):
|
||||
"""Test `Order.corrected` property."""
|
||||
setattr(order, f'{column}_corrected', True)
|
||||
setattr(order, f"{column}_corrected", True)
|
||||
|
||||
result = order.corrected
|
||||
|
||||
|
|
@ -784,14 +784,14 @@ class TestProperties:
|
|||
"""Test `Order.time_to_accept` property."""
|
||||
order.dispatch_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.time_to_accept)
|
||||
|
||||
def test_time_to_accept_no_courier_accepted(self, order):
|
||||
"""Test `Order.time_to_accept` property."""
|
||||
order.courier_accepted_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.time_to_accept)
|
||||
|
||||
def test_time_to_accept_success(self, order):
|
||||
|
|
@ -804,14 +804,14 @@ class TestProperties:
|
|||
"""Test `Order.time_to_react` property."""
|
||||
order.courier_notified_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.time_to_react)
|
||||
|
||||
def test_time_to_react_no_courier_accepted(self, order):
|
||||
"""Test `Order.time_to_react` property."""
|
||||
order.courier_accepted_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.time_to_react)
|
||||
|
||||
def test_time_to_react_success(self, order):
|
||||
|
|
@ -824,14 +824,14 @@ class TestProperties:
|
|||
"""Test `Order.time_to_pickup` property."""
|
||||
order.reached_pickup_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.time_to_pickup)
|
||||
|
||||
def test_time_to_pickup_no_courier_accepted(self, order):
|
||||
"""Test `Order.time_to_pickup` property."""
|
||||
order.courier_accepted_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.time_to_pickup)
|
||||
|
||||
def test_time_to_pickup_success(self, order):
|
||||
|
|
@ -844,14 +844,14 @@ class TestProperties:
|
|||
"""Test `Order.time_at_pickup` property."""
|
||||
order.reached_pickup_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.time_at_pickup)
|
||||
|
||||
def test_time_at_pickup_no_pickup_at(self, order):
|
||||
"""Test `Order.time_at_pickup` property."""
|
||||
order.pickup_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.time_at_pickup)
|
||||
|
||||
def test_time_at_pickup_success(self, order):
|
||||
|
|
@ -864,14 +864,14 @@ class TestProperties:
|
|||
"""Test `Order.scheduled_pickup_at` property."""
|
||||
order.restaurant_notified_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.scheduled_pickup_at)
|
||||
|
||||
def test_scheduled_pickup_at_no_est_prep_duration(self, order):
|
||||
"""Test `Order.scheduled_pickup_at` property."""
|
||||
order.estimated_prep_duration = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.scheduled_pickup_at)
|
||||
|
||||
def test_scheduled_pickup_at_success(self, order):
|
||||
|
|
@ -956,14 +956,14 @@ class TestProperties:
|
|||
"""Test `Order.time_to_delivery` property."""
|
||||
order.reached_delivery_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.time_to_delivery)
|
||||
|
||||
def test_time_to_delivery_no_pickup_at(self, order):
|
||||
"""Test `Order.time_to_delivery` property."""
|
||||
order.pickup_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.time_to_delivery)
|
||||
|
||||
def test_time_to_delivery_success(self, order):
|
||||
|
|
@ -976,14 +976,14 @@ class TestProperties:
|
|||
"""Test `Order.time_at_delivery` property."""
|
||||
order.reached_delivery_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.time_at_delivery)
|
||||
|
||||
def test_time_at_delivery_no_delivery_at(self, order):
|
||||
"""Test `Order.time_at_delivery` property."""
|
||||
order.delivery_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(order.time_at_delivery)
|
||||
|
||||
def test_time_at_delivery_success(self, order):
|
||||
|
|
@ -1011,7 +1011,7 @@ class TestProperties:
|
|||
def test_ad_hoc_order_cannot_be_early(self, order):
|
||||
"""Test `Order.delivery_early` property."""
|
||||
# By default, the `OrderFactory` creates ad-hoc orders.
|
||||
with pytest.raises(AttributeError, match='scheduled'):
|
||||
with pytest.raises(AttributeError, match="scheduled"):
|
||||
int(order.delivery_early)
|
||||
|
||||
def test_scheduled_order_delivered_early(self, make_order):
|
||||
|
|
@ -1037,7 +1037,7 @@ class TestProperties:
|
|||
def test_ad_hoc_order_cannot_be_late(self, order):
|
||||
"""Test Order.delivery_late property."""
|
||||
# By default, the `OrderFactory` creates ad-hoc orders.
|
||||
with pytest.raises(AttributeError, match='scheduled'):
|
||||
with pytest.raises(AttributeError, match="scheduled"):
|
||||
int(order.delivery_late)
|
||||
|
||||
def test_scheduled_order_delivered_late(self, make_order):
|
||||
|
|
@ -1064,14 +1064,14 @@ class TestProperties:
|
|||
"""Test `Order.total_time` property."""
|
||||
order = make_order(scheduled=True)
|
||||
|
||||
with pytest.raises(AttributeError, match='Scheduled'):
|
||||
with pytest.raises(AttributeError, match="Scheduled"):
|
||||
int(order.total_time)
|
||||
|
||||
def test_no_total_time_for_cancelled_order(self, make_order):
|
||||
"""Test `Order.total_time` property."""
|
||||
order = make_order(cancel_before_pickup=True)
|
||||
|
||||
with pytest.raises(RuntimeError, match='Cancelled'):
|
||||
with pytest.raises(RuntimeError, match="Cancelled"):
|
||||
int(order.total_time)
|
||||
|
||||
def test_total_time_success(self, order):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class TestSpecialMethods:
|
|||
"""`Pixel` has a non-literal text representation."""
|
||||
result = repr(pixel)
|
||||
|
||||
assert result == f'<Pixel: ({pixel.n_x}|{pixel.n_y})>'
|
||||
assert result == f"<Pixel: ({pixel.n_x}|{pixel.n_y})>"
|
||||
|
||||
|
||||
@pytest.mark.db
|
||||
|
|
@ -45,7 +45,7 @@ class TestConstraints:
|
|||
|
||||
with pytest.raises(
|
||||
sa_exc.IntegrityError,
|
||||
match='fk_pixels_to_grids_via_grid_id',
|
||||
match="fk_pixels_to_grids_via_grid_id",
|
||||
):
|
||||
db_session.execute(stmt)
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ class TestConstraints:
|
|||
pixel.n_x = -1
|
||||
db_session.add(pixel)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='n_x_is_positive'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="n_x_is_positive"):
|
||||
db_session.commit()
|
||||
|
||||
def test_negative_n_y(self, db_session, pixel):
|
||||
|
|
@ -62,7 +62,7 @@ class TestConstraints:
|
|||
pixel.n_y = -1
|
||||
db_session.add(pixel)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='n_y_is_positive'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="n_y_is_positive"):
|
||||
db_session.commit()
|
||||
|
||||
def test_non_unique_coordinates_within_a_grid(self, db_session, pixel):
|
||||
|
|
@ -70,7 +70,7 @@ class TestConstraints:
|
|||
another_pixel = db.Pixel(grid=pixel.grid, n_x=pixel.n_x, n_y=pixel.n_y)
|
||||
db_session.add(another_pixel)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match='duplicate key value'):
|
||||
with pytest.raises(sa_exc.IntegrityError, match="duplicate key value"):
|
||||
db_session.commit()
|
||||
|
||||
|
||||
|
|
@ -125,16 +125,16 @@ class TestProperties:
|
|||
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501
|
||||
)
|
||||
query.return_value = [restaurant]
|
||||
monkeypatch.setattr(db, 'session', mock)
|
||||
monkeypatch.setattr(db, "session", mock)
|
||||
|
||||
@pytest.mark.usefixtures('_restaurants_mock')
|
||||
@pytest.mark.usefixtures("_restaurants_mock")
|
||||
def test_restaurants(self, pixel, restaurant):
|
||||
"""Test `Pixel.restaurants` property."""
|
||||
result = pixel.restaurants
|
||||
|
||||
assert result == [restaurant]
|
||||
|
||||
@pytest.mark.usefixtures('_restaurants_mock')
|
||||
@pytest.mark.usefixtures("_restaurants_mock")
|
||||
def test_restaurants_is_cached(self, pixel):
|
||||
"""Test `Pixel.restaurants` property."""
|
||||
result1 = pixel.restaurants
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue