Remove periods from one-sentence comments
This commit is contained in:
parent
454c2898a0
commit
049a5f6f62
1 changed files with 308 additions and 308 deletions
|
|
@ -57,7 +57,7 @@ class TestConstraints:
|
|||
db_session.add(order)
|
||||
db_session.commit()
|
||||
|
||||
# Must delete without ORM as otherwise an UPDATE statement is emitted.
|
||||
# Must delete without ORM as otherwise an UPDATE statement is emitted
|
||||
stmt = sa.delete(db.Customer).where(db.Customer.id == order.customer.id)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_customers"):
|
||||
|
|
@ -68,7 +68,7 @@ class TestConstraints:
|
|||
db_session.add(order)
|
||||
db_session.commit()
|
||||
|
||||
# Must delete without ORM as otherwise an UPDATE statement is emitted.
|
||||
# Must delete without ORM as otherwise an UPDATE statement is emitted
|
||||
stmt = sa.delete(db.Courier).where(db.Courier.id == order.courier.id)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_couriers"):
|
||||
|
|
@ -79,7 +79,7 @@ class TestConstraints:
|
|||
db_session.add(order)
|
||||
db_session.commit()
|
||||
|
||||
# Must delete without ORM as otherwise an UPDATE statement is emitted.
|
||||
# Must delete without ORM as otherwise an UPDATE statement is emitted
|
||||
stmt = sa.delete(db.Restaurant).where(db.Restaurant.id == order.restaurant.id)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_restaurants"):
|
||||
|
|
@ -93,7 +93,7 @@ class TestConstraints:
|
|||
db_session.add(order)
|
||||
db_session.commit()
|
||||
|
||||
# Give the `restaurant` another `address`.
|
||||
# Give the `restaurant` another `address`
|
||||
order.restaurant.address = make_address()
|
||||
db_session.add(order.restaurant.address)
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ class TestConstraints:
|
|||
db_session.add(order)
|
||||
db_session.commit()
|
||||
|
||||
# Must delete without ORM as otherwise an UPDATE statement is emitted.
|
||||
# Must delete without ORM as otherwise an UPDATE statement is emitted
|
||||
stmt = sa.delete(db.Address).where(db.Address.id == order.delivery_address.id)
|
||||
|
||||
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_addresses"):
|
||||
|
|
@ -295,11 +295,11 @@ class TestConstraints:
|
|||
|
||||
# Make the `scheduled_delivery_at` the quarter of an hour
|
||||
# following the next quarter of an hour (i.e., the timestamp
|
||||
# is between 15 and 30 minutes into the future).
|
||||
# is between 15 and 30 minutes into the future)
|
||||
pre_order.ad_hoc = False
|
||||
minutes_to_next_quarter = 15 - (pre_order.placed_at.minute % 15)
|
||||
pre_order.scheduled_delivery_at = (
|
||||
# `.placed_at` may have non-0 seconds.
|
||||
# `.placed_at` may have non-0 seconds
|
||||
pre_order.placed_at.replace(second=0)
|
||||
+ dt.timedelta(minutes=(minutes_to_next_quarter + 15))
|
||||
)
|
||||
|
|
@ -434,22 +434,22 @@ class TestConstraints:
|
|||
There are two special cases for this test case below,
|
||||
where other attributes on `order` must be unset.
|
||||
"""
|
||||
# Set the actual timestamp to NULL.
|
||||
# Set the actual timestamp to NULL
|
||||
setattr(order, column, None)
|
||||
|
||||
# Setting both the timestamp and its correction column to NULL is allowed.
|
||||
# Setting both the timestamp and its correction column to NULL is allowed
|
||||
setattr(order, f"{column}_corrected", None)
|
||||
|
||||
db_session.add(order)
|
||||
db_session.commit()
|
||||
|
||||
# Also, an unset timestamp column may always be marked as corrected.
|
||||
# Also, an unset timestamp column may always be marked as corrected
|
||||
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.
|
||||
# Without a timestamp set, a column may not be marked as uncorrected
|
||||
setattr(order, f"{column}_corrected", False)
|
||||
|
||||
db_session.add(order)
|
||||
|
|
@ -518,10 +518,10 @@ class TestConstraints:
|
|||
There are two special cases for this test case below,
|
||||
where other attributes on `order` must be unset.
|
||||
"""
|
||||
# Ensure the timestamp is set.
|
||||
# Ensure the timestamp is set
|
||||
assert getattr(order, column) is not None
|
||||
|
||||
# A set timestamp may be marked as either corrected or uncorrected.
|
||||
# A set timestamp may be marked as either corrected or uncorrected
|
||||
|
||||
setattr(order, f"{column}_corrected", True)
|
||||
|
||||
|
|
@ -533,7 +533,7 @@ class TestConstraints:
|
|||
db_session.add(order)
|
||||
db_session.commit()
|
||||
|
||||
# A set timestamp may not be left unmarked.
|
||||
# A set timestamp may not be left unmarked
|
||||
setattr(order, f"{column}_corrected", None)
|
||||
|
||||
db_session.add(order)
|
||||
|
|
@ -659,7 +659,7 @@ class TestConstraints:
|
|||
This is one of two special cases. See the generic case above.
|
||||
"""
|
||||
# As we subtract 1 second in the generic case,
|
||||
# choose one second after a quarter of an hour.
|
||||
# choose one second after a quarter of an hour
|
||||
pre_order.placed_at = dt.datetime(*test_config.DATE, 11, 45, 1)
|
||||
self.test_timestamps_unordered(
|
||||
db_session,
|
||||
|
|
@ -752,7 +752,7 @@ class TestProperties:
|
|||
|
||||
def test_is_not_corrected(self, order):
|
||||
"""Test `Order.corrected` property."""
|
||||
# By default, the `OrderFactory` sets all `.*_corrected` attributes to `False`.
|
||||
# By default, the `OrderFactory` sets all `.*_corrected` attributes to `False`
|
||||
result = order.corrected
|
||||
|
||||
assert result is False
|
||||
|
|
@ -882,7 +882,7 @@ class TestProperties:
|
|||
|
||||
def test_courier_is_early_at_pickup(self, order):
|
||||
"""Test `Order.courier_early` property."""
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`.
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`
|
||||
order.estimated_prep_duration = 999_999
|
||||
|
||||
result = order.courier_early
|
||||
|
|
@ -891,7 +891,7 @@ class TestProperties:
|
|||
|
||||
def test_courier_is_not_early_at_pickup(self, order):
|
||||
"""Test `Order.courier_early` property."""
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`.
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`
|
||||
order.estimated_prep_duration = 1
|
||||
|
||||
result = order.courier_early
|
||||
|
|
@ -900,7 +900,7 @@ class TestProperties:
|
|||
|
||||
def test_courier_is_late_at_pickup(self, order):
|
||||
"""Test `Order.courier_late` property."""
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`.
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`
|
||||
order.estimated_prep_duration = 1
|
||||
|
||||
result = order.courier_late
|
||||
|
|
@ -909,7 +909,7 @@ class TestProperties:
|
|||
|
||||
def test_courier_is_not_late_at_pickup(self, order):
|
||||
"""Test `Order.courier_late` property."""
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`.
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`
|
||||
order.estimated_prep_duration = 999_999
|
||||
|
||||
result = order.courier_late
|
||||
|
|
@ -932,7 +932,7 @@ class TestProperties:
|
|||
|
||||
def test_restaurant_early_at_pickup(self, order):
|
||||
"""Test `Order.restaurant_early` property."""
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`.
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`
|
||||
order.estimated_prep_duration = 999_999
|
||||
|
||||
result = order.restaurant_early
|
||||
|
|
@ -941,7 +941,7 @@ class TestProperties:
|
|||
|
||||
def test_restaurant_is_not_early_at_pickup(self, order):
|
||||
"""Test `Order.restaurant_early` property."""
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`.
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`
|
||||
order.estimated_prep_duration = 1
|
||||
|
||||
result = order.restaurant_early
|
||||
|
|
@ -950,7 +950,7 @@ class TestProperties:
|
|||
|
||||
def test_restaurant_is_late_at_pickup(self, order):
|
||||
"""Test `Order.restaurant_late` property."""
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`.
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`
|
||||
order.estimated_prep_duration = 1
|
||||
|
||||
result = order.restaurant_late
|
||||
|
|
@ -959,7 +959,7 @@ class TestProperties:
|
|||
|
||||
def test_restaurant_is_not_late_at_pickup(self, order):
|
||||
"""Test `Order.restaurant_late` property."""
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`.
|
||||
# Manipulate the attribute that determines `Order.scheduled_pickup_at`
|
||||
order.estimated_prep_duration = 999_999
|
||||
|
||||
result = order.restaurant_late
|
||||
|
|
@ -1038,14 +1038,14 @@ 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.
|
||||
# By default, the `OrderFactory` creates ad-hoc orders
|
||||
with pytest.raises(AttributeError, match="scheduled"):
|
||||
int(order.delivery_early)
|
||||
|
||||
def test_scheduled_order_delivered_early(self, make_order):
|
||||
"""Test `Order.delivery_early` property."""
|
||||
order = make_order(scheduled=True)
|
||||
# Schedule the order to a lot later.
|
||||
# Schedule the order to a lot later
|
||||
order.scheduled_delivery_at += dt.timedelta(hours=2)
|
||||
|
||||
result = order.delivery_early
|
||||
|
|
@ -1055,7 +1055,7 @@ class TestProperties:
|
|||
def test_scheduled_order_not_delivered_early(self, make_order):
|
||||
"""Test `Order.delivery_early` property."""
|
||||
order = make_order(scheduled=True)
|
||||
# Schedule the order to a lot earlier.
|
||||
# Schedule the order to a lot earlier
|
||||
order.scheduled_delivery_at -= dt.timedelta(hours=2)
|
||||
|
||||
result = order.delivery_early
|
||||
|
|
@ -1080,14 +1080,14 @@ 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.
|
||||
# By default, the `OrderFactory` creates ad-hoc orders
|
||||
with pytest.raises(AttributeError, match="scheduled"):
|
||||
int(order.delivery_late)
|
||||
|
||||
def test_scheduled_order_delivered_late(self, make_order):
|
||||
"""Test `Order.delivery_early` property."""
|
||||
order = make_order(scheduled=True)
|
||||
# Schedule the order to a lot earlier.
|
||||
# Schedule the order to a lot earlier
|
||||
order.scheduled_delivery_at -= dt.timedelta(hours=2)
|
||||
|
||||
result = order.delivery_late
|
||||
|
|
@ -1097,7 +1097,7 @@ class TestProperties:
|
|||
def test_scheduled_order_not_delivered_late(self, make_order):
|
||||
"""Test `Order.delivery_early` property."""
|
||||
order = make_order(scheduled=True)
|
||||
# Schedule the order to a lot later.
|
||||
# Schedule the order to a lot later
|
||||
order.scheduled_delivery_at += dt.timedelta(hours=2)
|
||||
|
||||
result = order.delivery_late
|
||||
|
|
@ -1162,23 +1162,23 @@ def test_make_random_orders(
|
|||
Ensure that all generated `Address`, `Courier`, `Customer`, `Restaurant`,
|
||||
and `Order` objects adhere to the database constraints.
|
||||
"""
|
||||
# Generate a large number of `Order`s to obtain a large variance of data.
|
||||
# Generate a large number of `Order`s to obtain a large variance of data
|
||||
for _ in range(1_000):
|
||||
# Ad-hoc `Order`s are far more common than pre-orders.
|
||||
# Ad-hoc `Order`s are far more common than pre-orders
|
||||
scheduled = random.choice([True, False, False, False, False])
|
||||
|
||||
# Randomly pass a `address` argument to `make_restaurant()` and
|
||||
# a `restaurant` argument to `make_order()`.
|
||||
# a `restaurant` argument to `make_order()`
|
||||
if random.random() < 0.5:
|
||||
address = random.choice([None, make_address()])
|
||||
restaurant = make_restaurant(address=address)
|
||||
else:
|
||||
restaurant = None
|
||||
|
||||
# Randomly pass a `courier` argument to `make_order()`.
|
||||
# Randomly pass a `courier` argument to `make_order()`
|
||||
courier = random.choice([None, make_courier()])
|
||||
|
||||
# A tiny fraction of `Order`s get cancelled.
|
||||
# A tiny fraction of `Order`s get cancelled
|
||||
if random.random() < 0.05:
|
||||
if random.random() < 0.5:
|
||||
cancel_before_pickup, cancel_after_pickup = True, False
|
||||
|
|
|
|||
Loading…
Reference in a new issue