Reword the comments in the test suite
Each comment is one sentence or two short ones joined by "=>", without a final period.
This commit is contained in:
parent
0f69709226
commit
bca4250b4d
6 changed files with 39 additions and 59 deletions
|
|
@ -20,10 +20,8 @@ class AddressFactory(alchemy.SQLAlchemyModelFactory):
|
|||
id = factory.Sequence(lambda num: num)
|
||||
created_at = factory.LazyFunction(utils.early_in_the_morning)
|
||||
|
||||
# When testing, all addresses are considered primary ones.
|
||||
# As non-primary addresses have no different behavior
|
||||
# and the property is only kept from the original dataset for
|
||||
# completeness sake, that is ok to do.
|
||||
# Non-primary addresses behave no differently in the tests
|
||||
# => Treat all addresses as primary ones
|
||||
primary_id = factory.LazyAttribute(lambda obj: obj.id)
|
||||
|
||||
# Mimic a Google Maps Place ID with just random characters
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ class AdHocOrderFactory(alchemy.SQLAlchemyModelFactory):
|
|||
id = factory.Sequence(lambda num: num)
|
||||
# customer -> set by the `make_order` fixture for better control
|
||||
|
||||
# Attributes regarding the specialization of an `Order`: ad-hoc or scheduled.
|
||||
# Ad-hoc `Order`s are placed between 11.45 and 14.15.
|
||||
# Attributes regarding the specialization of an `Order`: ad-hoc or scheduled
|
||||
# Ad-hoc `Order`s are placed between 11.45 and 14.15
|
||||
placed_at = factory.LazyFunction(
|
||||
lambda: (
|
||||
dt.datetime(*test_config.DATE, 11, 45)
|
||||
|
|
@ -88,8 +88,8 @@ class AdHocOrderFactory(alchemy.SQLAlchemyModelFactory):
|
|||
lambda obj: obj.placed_at + dt.timedelta(minutes=45),
|
||||
)
|
||||
|
||||
# Attributes regarding the cancellation of an `Order`.
|
||||
# May be overwritten with the `cancel_before_pickup` or `cancel_after_pickup` flags.
|
||||
# Attributes regarding the cancellation of an `Order`
|
||||
# May be overwritten with the `cancel_before_pickup` or `cancel_after_pickup` flags
|
||||
cancelled = False
|
||||
cancelled_at = None
|
||||
cancelled_at_corrected = None
|
||||
|
|
|
|||
|
|
@ -298,13 +298,11 @@ class TestConstraints:
|
|||
|
||||
Scheduled orders must be at least 30 minutes into the future.
|
||||
"""
|
||||
# Create an ad-hoc order first and then make that a scheduled order.
|
||||
# This way, it is less work to keep the timestamps consistent.
|
||||
# Turning an ad-hoc order into a scheduled one keeps the timestamps consistent
|
||||
replay_pre_order = make_replay_order(scheduled=False)
|
||||
|
||||
# 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)
|
||||
# Schedule the delivery at the quarter of an hour after the next one
|
||||
# => It is 15 to 30 minutes into the future
|
||||
replay_pre_order.ad_hoc = False
|
||||
replay_pre_order.actual.ad_hoc = False
|
||||
minutes_to_next_quarter = 15 - (replay_pre_order.placed_at.minute % 15)
|
||||
|
|
|
|||
|
|
@ -383,9 +383,8 @@ class TestSyncWithGoogleMaps:
|
|||
"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
|
||||
# An artificially high distance of `9999` ensures
|
||||
# that the synced bicycle distance exceeds the fake air distance
|
||||
"distance": {"text": "3.0 km", "value": 9999},
|
||||
"duration": {"text": "10 mins", "value": 596},
|
||||
"end_address": "13 Place Paul et Jean Paul Avisseau, ...",
|
||||
|
|
|
|||
|
|
@ -115,8 +115,8 @@ class TestGridification:
|
|||
"""
|
||||
addresses_mock.return_value = []
|
||||
|
||||
# The chosen `side_length` would result in one `Pixel` if there were orders.
|
||||
# `+1` as otherwise there would be a second pixel in one direction.
|
||||
# One `Pixel` would cover the whole `city` if there were orders
|
||||
# => `+1` as otherwise there would be a second one in one direction
|
||||
side_length = max(city.total_x, city.total_y) + 1
|
||||
|
||||
result = db.Grid.gridify(city=city, side_length=side_length)
|
||||
|
|
@ -203,7 +203,7 @@ class TestGridification:
|
|||
addresses_mock.return_value = [
|
||||
# One `Address` in the lower-left `Pixel`, ...
|
||||
make_address(latitude=48.8357377, longitude=2.2517412),
|
||||
# ... and another one in the upper-right one.
|
||||
# ... and another one in the upper-right one
|
||||
make_address(latitude=48.8898312, longitude=2.4357622),
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -100,11 +100,8 @@ class TestConstraints:
|
|||
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 `test_delete_a_referenced_pickup_address(self, db_session, order)`.
|
||||
# The corresponding "fk_orders_to_addresses_on_pickup_address_id" constraint
|
||||
# is very hard to test in isolation as the above "fk_orders_to_restaurants_..."
|
||||
# constraint ensures its integrity already.
|
||||
# No test for "fk_orders_to_addresses_on_pickup_address_id" as the
|
||||
# "fk_orders_to_restaurants_..." constraint already ensures its integrity
|
||||
|
||||
def test_delete_a_referenced_delivery_address(self, db_session, order):
|
||||
"""Remove a record that is referenced with a FK."""
|
||||
|
|
@ -289,13 +286,11 @@ class TestConstraints:
|
|||
|
||||
Scheduled orders must be at least 30 minutes into the future.
|
||||
"""
|
||||
# Create an ad-hoc order first and then make that a scheduled order.
|
||||
# This way, it is less work to keep the timestamps consistent.
|
||||
# Turning an ad-hoc order into a scheduled one keeps the timestamps consistent
|
||||
pre_order = make_order(scheduled=False)
|
||||
|
||||
# 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)
|
||||
# Schedule the delivery at the quarter of an hour after the next one
|
||||
# => It is 15 to 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 = (
|
||||
|
|
@ -1187,8 +1182,8 @@ def test_make_random_orders(
|
|||
else:
|
||||
cancel_before_pickup, cancel_after_pickup = False, False
|
||||
|
||||
# Write all the generated objects to the database.
|
||||
# This should already trigger an `IntegrityError` if the data are flawed.
|
||||
# Writing all generated objects to the database checks their integrity
|
||||
# => An `IntegrityError` here means the fake data are flawed
|
||||
order = make_order(
|
||||
scheduled=scheduled,
|
||||
restaurant=restaurant,
|
||||
|
|
|
|||
Loading…
Reference in a new issue