diff --git a/src/velofy/db/addresses_addresses.py b/src/velofy/db/addresses_addresses.py index 0ab22f1..682f111 100644 --- a/src/velofy/db/addresses_addresses.py +++ b/src/velofy/db/addresses_addresses.py @@ -270,6 +270,9 @@ class Path(meta.Base): Implementation detail: This property is cached as none of the underlying attributes (i.e., `._directions`) are to be changed. """ + if not self._directions: + raise RuntimeError("_directions is not set") + points = [utils.Location(*point) for point in json.loads(self._directions)] for point in points: point.relate_to(self.first_address.city.southwest) diff --git a/tests/db/test_addresses_addresses.py b/tests/db/test_addresses_addresses.py index e4fdb6d..9d9f91d 100644 --- a/tests/db/test_addresses_addresses.py +++ b/tests/db/test_addresses_addresses.py @@ -670,6 +670,13 @@ class TestSyncWithGoogleMaps: class TestProperties: """Test properties in `Path`.""" + def test_waypoints_no_directions(self, path): + """Test `Path.waypoints` property.""" + path._directions = None + + with pytest.raises(RuntimeError, match="not set"): + int(path.waypoints) + def test_waypoints_structure(self, path): """Test `Path.waypoints` property.""" result = path.waypoints