Use a unified DATE constant for convenience
This commit is contained in:
parent
f0eb9d3b6f
commit
41f75f507d
6 changed files with 21 additions and 55 deletions
|
@ -7,6 +7,8 @@ from urban_meal_delivery import config
|
|||
|
||||
# The day on which most test cases take place.
|
||||
YEAR, MONTH, DAY = 2016, 7, 1
|
||||
# Same day as a `tuple`.
|
||||
DATE = (YEAR, MONTH, DAY)
|
||||
|
||||
# The hour when most test cases take place.
|
||||
NOON = 12
|
||||
|
|
|
@ -70,9 +70,7 @@ class AdHocOrderFactory(alchemy.SQLAlchemyModelFactory):
|
|||
# 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.YEAR, test_config.MONTH, test_config.DAY, 11, 45,
|
||||
)
|
||||
lambda: dt.datetime(*test_config.DATE, 11, 45)
|
||||
+ utils.random_timespan(max_hours=2, max_minutes=30),
|
||||
)
|
||||
ad_hoc = True
|
||||
|
|
|
@ -27,27 +27,13 @@ class ScheduledOrderFactory(ad_hoc.AdHocOrderFactory):
|
|||
scheduled_delivery_at = factory.LazyFunction(
|
||||
lambda: random.choice(
|
||||
[
|
||||
dt.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, 12, 0,
|
||||
),
|
||||
dt.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, 12, 15,
|
||||
),
|
||||
dt.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, 12, 30,
|
||||
),
|
||||
dt.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, 12, 45,
|
||||
),
|
||||
dt.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, 13, 0,
|
||||
),
|
||||
dt.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, 13, 15,
|
||||
),
|
||||
dt.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, 13, 30,
|
||||
),
|
||||
dt.datetime(*test_config.DATE, 12, 0),
|
||||
dt.datetime(*test_config.DATE, 12, 15),
|
||||
dt.datetime(*test_config.DATE, 12, 30),
|
||||
dt.datetime(*test_config.DATE, 12, 45),
|
||||
dt.datetime(*test_config.DATE, 13, 0),
|
||||
dt.datetime(*test_config.DATE, 13, 15),
|
||||
dt.datetime(*test_config.DATE, 13, 30),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
|
|
@ -23,5 +23,5 @@ def random_timespan( # noqa:WPS211
|
|||
|
||||
def early_in_the_morning():
|
||||
"""A randomized `datetime` object early in the morning."""
|
||||
early = dt.datetime(test_config.YEAR, test_config.MONTH, test_config.DAY, 3, 0)
|
||||
early = dt.datetime(*test_config.DATE, 3, 0)
|
||||
return early + random_timespan(max_hours=2)
|
||||
|
|
|
@ -17,9 +17,7 @@ def horizontal_datetime_index():
|
|||
The times resemble a horizontal time series with a `frequency` of `7`.
|
||||
All observations take place at `NOON`.
|
||||
"""
|
||||
first_start_at = dt.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, test_config.NOON, 0,
|
||||
)
|
||||
first_start_at = dt.datetime(*test_config.DATE, test_config.NOON, 0)
|
||||
|
||||
gen = (
|
||||
start_at
|
||||
|
|
|
@ -73,9 +73,7 @@ class TestAggregateOrders:
|
|||
order = make_order(
|
||||
scheduled=False,
|
||||
restaurant=restaurant,
|
||||
placed_at=datetime.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, hour, 11,
|
||||
),
|
||||
placed_at=datetime.datetime(*test_config.DATE, hour, 11),
|
||||
)
|
||||
db_session.add(order)
|
||||
|
||||
|
@ -104,9 +102,7 @@ class TestAggregateOrders:
|
|||
order = make_order(
|
||||
scheduled=False,
|
||||
restaurant=restaurant,
|
||||
placed_at=datetime.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, hour, 11,
|
||||
),
|
||||
placed_at=datetime.datetime(*test_config.DATE, hour, 11),
|
||||
)
|
||||
db_session.add(order)
|
||||
|
||||
|
@ -137,9 +133,7 @@ class TestAggregateOrders:
|
|||
order = make_order(
|
||||
scheduled=False,
|
||||
restaurant=restaurant,
|
||||
placed_at=datetime.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, hour, 11,
|
||||
),
|
||||
placed_at=datetime.datetime(*test_config.DATE, hour, 11),
|
||||
)
|
||||
db_session.add(order)
|
||||
|
||||
|
@ -169,21 +163,15 @@ class TestAggregateOrders:
|
|||
ad_hoc_order = make_order(
|
||||
scheduled=False,
|
||||
restaurant=restaurant,
|
||||
placed_at=datetime.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, 11, 11,
|
||||
),
|
||||
placed_at=datetime.datetime(*test_config.DATE, 11, 11),
|
||||
)
|
||||
db_session.add(ad_hoc_order)
|
||||
|
||||
pre_order = make_order(
|
||||
scheduled=True,
|
||||
restaurant=restaurant,
|
||||
placed_at=datetime.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, 9, 0,
|
||||
),
|
||||
scheduled_delivery_at=datetime.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, 12, 0,
|
||||
),
|
||||
placed_at=datetime.datetime(*test_config.DATE, 9, 0),
|
||||
scheduled_delivery_at=datetime.datetime(*test_config.DATE, 12, 0),
|
||||
)
|
||||
db_session.add(pre_order)
|
||||
|
||||
|
@ -215,9 +203,7 @@ class TestAggregateOrders:
|
|||
order = make_order(
|
||||
scheduled=False,
|
||||
restaurant=restaurant,
|
||||
placed_at=datetime.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, hour, 11,
|
||||
),
|
||||
placed_at=datetime.datetime(*test_config.DATE, hour, 11),
|
||||
)
|
||||
db_session.add(order)
|
||||
|
||||
|
@ -252,9 +238,7 @@ class TestAggregateOrders:
|
|||
order = make_order(
|
||||
scheduled=False,
|
||||
restaurant=restaurant,
|
||||
placed_at=datetime.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, hour, 11,
|
||||
),
|
||||
placed_at=datetime.datetime(*test_config.DATE, hour, 11),
|
||||
)
|
||||
db_session.add(order)
|
||||
|
||||
|
@ -333,9 +317,7 @@ class TestAggregateOrders:
|
|||
order = make_order(
|
||||
scheduled=False,
|
||||
restaurant=restaurant1,
|
||||
placed_at=datetime.datetime(
|
||||
test_config.YEAR, test_config.MONTH, test_config.DAY, hour, 11,
|
||||
),
|
||||
placed_at=datetime.datetime(*test_config.DATE, hour, 11),
|
||||
)
|
||||
db_session.add(order)
|
||||
|
||||
|
|
Loading…
Reference in a new issue