Remove all "WPS" codes
This commit is contained in:
parent
8a5a652b3e
commit
9fcb3c8c14
12 changed files with 171 additions and 254 deletions
|
|
@ -17,7 +17,7 @@ class AddressFactory(alchemy.SQLAlchemyModelFactory):
|
|||
model = db.Address
|
||||
sqlalchemy_get_or_create = ('id',)
|
||||
|
||||
id = factory.Sequence(lambda num: num) # noqa:WPS125
|
||||
id = factory.Sequence(lambda num: num)
|
||||
created_at = factory.LazyFunction(utils.early_in_the_morning)
|
||||
|
||||
# When testing, all addresses are considered primary ones.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class CourierFactory(alchemy.SQLAlchemyModelFactory):
|
|||
model = db.Courier
|
||||
sqlalchemy_get_or_create = ('id',)
|
||||
|
||||
id = factory.Sequence(lambda num: num) # noqa:WPS125
|
||||
id = factory.Sequence(lambda num: num)
|
||||
created_at = factory.LazyFunction(utils.early_in_the_morning)
|
||||
vehicle = 'bicycle'
|
||||
historic_speed = 7.89
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ class CustomerFactory(alchemy.SQLAlchemyModelFactory):
|
|||
model = db.Customer
|
||||
sqlalchemy_get_or_create = ('id',)
|
||||
|
||||
id = factory.Sequence(lambda num: num) # noqa:WPS125
|
||||
id = factory.Sequence(lambda num: num)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class AdHocOrderFactory(alchemy.SQLAlchemyModelFactory):
|
|||
|
||||
# Timestamps after `cancelled_at` are discarded
|
||||
# by the `post_generation` hook at the end of the `OrderFactory`.
|
||||
cancel_ = factory.Trait( # noqa:WPS120 -> leading underscore does not work
|
||||
cancel_ = factory.Trait( # -> leading underscore does not work
|
||||
cancelled=True,
|
||||
cancelled_at_corrected=False,
|
||||
)
|
||||
|
|
@ -65,7 +65,7 @@ class AdHocOrderFactory(alchemy.SQLAlchemyModelFactory):
|
|||
)
|
||||
|
||||
# Generic attributes
|
||||
id = factory.Sequence(lambda num: num) # noqa:WPS125
|
||||
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.
|
||||
|
|
@ -182,7 +182,7 @@ class AdHocOrderFactory(alchemy.SQLAlchemyModelFactory):
|
|||
|
||||
# Statistical attributes -> calculate realistic stats
|
||||
logged_delivery_distance = factory.LazyAttribute(
|
||||
lambda obj: distance.great_circle( # noqa:WPS317
|
||||
lambda obj: distance.great_circle(
|
||||
(obj.pickup_address.latitude, obj.pickup_address.longitude),
|
||||
(obj.delivery_address.latitude, obj.delivery_address.longitude),
|
||||
).meters,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class RestaurantFactory(alchemy.SQLAlchemyModelFactory):
|
|||
model = db.Restaurant
|
||||
sqlalchemy_get_or_create = ('id',)
|
||||
|
||||
id = factory.Sequence(lambda num: num) # noqa:WPS125
|
||||
id = factory.Sequence(lambda num: num)
|
||||
created_at = factory.LazyFunction(utils.early_in_the_morning)
|
||||
name = factory.LazyFunction(
|
||||
lambda: f"{_restaurant_names.first_name()}'s Restaurant",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import random
|
|||
from tests import config as test_config
|
||||
|
||||
|
||||
def random_timespan( # noqa:WPS211
|
||||
def random_timespan(
|
||||
*,
|
||||
min_hours=0,
|
||||
min_minutes=0,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ def another_address(make_address):
|
|||
@pytest.fixture
|
||||
def path(address, another_address, make_address):
|
||||
"""A `Path` from `address` to `another_address`."""
|
||||
air_distance = distance.great_circle( # noqa:WPS317
|
||||
air_distance = distance.great_circle(
|
||||
address.location.lat_lng,
|
||||
another_address.location.lat_lng,
|
||||
).meters
|
||||
|
|
@ -31,7 +31,7 @@ def path(address, another_address, make_address):
|
|||
directions = json.dumps(
|
||||
[
|
||||
(float(add.latitude), float(add.longitude))
|
||||
for add in (make_address() for _ in range(5)) # noqa:WPS335
|
||||
for add in (make_address() for _ in range(5))
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@ class TestConstraints:
|
|||
forecast.low95 = None
|
||||
forecast.high95 = None
|
||||
|
||||
forecast.low80, forecast.high80 = ( # noqa:WPS414
|
||||
forecast.low80, forecast.high80 = (
|
||||
forecast.high80,
|
||||
forecast.low80,
|
||||
)
|
||||
|
|
@ -398,7 +398,7 @@ class TestConstraints:
|
|||
forecast.low80 = None
|
||||
forecast.high80 = None
|
||||
|
||||
forecast.low95, forecast.high95 = ( # noqa:WPS414
|
||||
forecast.low95, forecast.high95 = (
|
||||
forecast.high95,
|
||||
forecast.low95,
|
||||
)
|
||||
|
|
@ -416,7 +416,7 @@ class TestConstraints:
|
|||
assert forecast.low80 is not None
|
||||
assert forecast.low95 is not None
|
||||
|
||||
forecast.low80, forecast.low95 = (forecast.low95, forecast.low80) # noqa:WPS414
|
||||
forecast.low80, forecast.low95 = (forecast.low95, forecast.low80)
|
||||
|
||||
db_session.add(forecast)
|
||||
|
||||
|
|
@ -431,7 +431,7 @@ class TestConstraints:
|
|||
assert forecast.high80 is not None
|
||||
assert forecast.high95 is not None
|
||||
|
||||
forecast.high80, forecast.high95 = ( # noqa:WPS414
|
||||
forecast.high80, forecast.high95 = (
|
||||
forecast.high95,
|
||||
forecast.high80,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class TestGridification:
|
|||
"""
|
||||
mock = mocker.Mock()
|
||||
query = ( # noqa:ECE001
|
||||
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501,WPS219
|
||||
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501
|
||||
)
|
||||
monkeypatch.setattr(db, 'session', mock)
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ class TestGridification:
|
|||
result = db.Grid.gridify(city=city, side_length=side_length)
|
||||
|
||||
assert isinstance(result, db.Grid)
|
||||
assert len(result.pixels) == 0 # noqa:WPS507
|
||||
assert len(result.pixels) == 0
|
||||
|
||||
def test_one_pixel_with_one_address(self, city, order, addresses_mock):
|
||||
"""At the very least, there must be one `Pixel` ...
|
||||
|
|
@ -155,7 +155,7 @@ class TestGridification:
|
|||
result = db.Grid.gridify(city=city, side_length=side_length)
|
||||
|
||||
assert isinstance(result, db.Grid)
|
||||
assert len(result.pixels) == 0 # noqa:WPS507
|
||||
assert len(result.pixels) == 0
|
||||
|
||||
@pytest.mark.no_cover
|
||||
def test_no_pixel_with_one_address_too_far_west(self, city, order, addresses_mock):
|
||||
|
|
@ -174,7 +174,7 @@ class TestGridification:
|
|||
result = db.Grid.gridify(city=city, side_length=side_length)
|
||||
|
||||
assert isinstance(result, db.Grid)
|
||||
assert len(result.pixels) == 0 # noqa:WPS507
|
||||
assert len(result.pixels) == 0
|
||||
|
||||
@pytest.mark.no_cover
|
||||
def test_two_pixels_with_two_addresses(self, city, make_address, addresses_mock):
|
||||
|
|
@ -206,7 +206,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])
|
||||
def test_make_random_grids( # noqa:WPS211,WPS218
|
||||
def test_make_random_grids(
|
||||
self,
|
||||
db_session,
|
||||
city,
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ class TestConstraints:
|
|||
'left_pickup_at',
|
||||
],
|
||||
)
|
||||
def test_unset_timestamp_column_not_marked_as_uncorrected( # noqa:WPS213
|
||||
def test_unset_timestamp_column_not_marked_as_uncorrected(
|
||||
self,
|
||||
db_session,
|
||||
order,
|
||||
|
|
@ -507,7 +507,7 @@ class TestConstraints:
|
|||
'delivery_at',
|
||||
],
|
||||
)
|
||||
def test_set_timestamp_column_is_not_unmarked( # noqa:WPS213
|
||||
def test_set_timestamp_column_is_not_unmarked(
|
||||
self,
|
||||
db_session,
|
||||
order,
|
||||
|
|
@ -860,14 +860,14 @@ class TestProperties:
|
|||
|
||||
assert result > dt.timedelta(0)
|
||||
|
||||
def test_scheduled_pickup_at_no_restaurant_notified(self, order): # noqa:WPS118
|
||||
def test_scheduled_pickup_at_no_restaurant_notified(self, order):
|
||||
"""Test `Order.scheduled_pickup_at` property."""
|
||||
order.restaurant_notified_at = None
|
||||
|
||||
with pytest.raises(RuntimeError, match='not set'):
|
||||
int(order.scheduled_pickup_at)
|
||||
|
||||
def test_scheduled_pickup_at_no_est_prep_duration(self, order): # noqa:WPS118
|
||||
def test_scheduled_pickup_at_no_est_prep_duration(self, order):
|
||||
"""Test `Order.scheduled_pickup_at` property."""
|
||||
order.estimated_prep_duration = None
|
||||
|
||||
|
|
@ -952,7 +952,7 @@ class TestProperties:
|
|||
|
||||
assert bool(result) is False
|
||||
|
||||
def test_time_to_delivery_no_reached_delivery_at(self, order): # noqa:WPS118
|
||||
def test_time_to_delivery_no_reached_delivery_at(self, order):
|
||||
"""Test `Order.time_to_delivery` property."""
|
||||
order.reached_delivery_at = None
|
||||
|
||||
|
|
@ -972,7 +972,7 @@ class TestProperties:
|
|||
|
||||
assert result > dt.timedelta(0)
|
||||
|
||||
def test_time_at_delivery_no_reached_delivery_at(self, order): # noqa:WPS118
|
||||
def test_time_at_delivery_no_reached_delivery_at(self, order):
|
||||
"""Test `Order.time_at_delivery` property."""
|
||||
order.reached_delivery_at = None
|
||||
|
||||
|
|
@ -1083,7 +1083,7 @@ class TestProperties:
|
|||
|
||||
@pytest.mark.db
|
||||
@pytest.mark.no_cover
|
||||
def test_make_random_orders( # noqa:C901,WPS211,WPS213
|
||||
def test_make_random_orders( # noqa:C901
|
||||
db_session,
|
||||
make_address,
|
||||
make_courier,
|
||||
|
|
@ -1096,7 +1096,7 @@ def test_make_random_orders( # noqa:C901,WPS211,WPS213
|
|||
and `Order` objects adhere to the database constraints.
|
||||
""" # noqa:D202
|
||||
# Generate a large number of `Order`s to obtain a large variance of data.
|
||||
for _ in range(1_000): # noqa:WPS122
|
||||
for _ in range(1_000):
|
||||
|
||||
# Ad-hoc `Order`s are far more common than pre-orders.
|
||||
scheduled = random.choice([True, False, False, False, False])
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class TestProperties:
|
|||
"""A `Mock` whose `.return_value` is `[restaurant]`."""
|
||||
mock = mocker.Mock()
|
||||
query = ( # noqa:ECE001
|
||||
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501,WPS219
|
||||
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501
|
||||
)
|
||||
query.return_value = [restaurant]
|
||||
monkeypatch.setattr(db, 'session', mock)
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class TestSpecialMethods:
|
|||
|
||||
def test_compare_utm_coordinates_to_themselves(self, location):
|
||||
"""Test `Location.__eq__()`."""
|
||||
result = location == location # noqa:WPS312
|
||||
result = location == location
|
||||
|
||||
assert result is True
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue