Integrate the new Location class
- the old `UTMCoordinate` class becomes the new `Location` class - its main purpose is to represent locations in both lat-long coordinates as well as in the UTM system - remove `Address.__init__()` and `City.__init__()` methods as they are not executed for entries retrieved from the database - simplfiy the `Location.__init__()` => remove `relative_to` argument
This commit is contained in:
parent
2e3ccd14d5
commit
a1cbb808fd
8 changed files with 198 additions and 157 deletions
|
|
@ -6,6 +6,7 @@ import sqlalchemy as sqla
|
|||
from sqlalchemy import exc as sa_exc
|
||||
|
||||
from urban_meal_delivery import db
|
||||
from urban_meal_delivery.db import utils
|
||||
|
||||
|
||||
class TestSpecialMethods:
|
||||
|
|
@ -123,6 +124,24 @@ class TestProperties:
|
|||
|
||||
assert result is False
|
||||
|
||||
def test_location(self, address):
|
||||
"""Test `Address.location` property."""
|
||||
latitude = float(address.latitude)
|
||||
longitude = float(address.longitude)
|
||||
|
||||
result = address.location
|
||||
|
||||
assert isinstance(result, utils.Location)
|
||||
assert result.latitude == pytest.approx(latitude)
|
||||
assert result.longitude == pytest.approx(longitude)
|
||||
|
||||
def test_location_is_cached(self, address):
|
||||
"""Test `Address.location` property."""
|
||||
result1 = address.location
|
||||
result2 = address.location
|
||||
|
||||
assert result1 is result2
|
||||
|
||||
def test_x_is_positive(self, address):
|
||||
"""Test `Address.x` property."""
|
||||
result = address.x
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue