fixed comparison logic for waypoints and added tests to help catch issue in the future
This commit is contained in:
parent
471f40a0bd
commit
8572e153f4
2 changed files with 21 additions and 4 deletions
|
@ -570,10 +570,10 @@ class WayPoint:
|
|||
return not self == other
|
||||
|
||||
def __lt__(self, other: "WayPoint") -> bool:
|
||||
result = self.time < other.time
|
||||
if result:
|
||||
result = self.nodenum < other.nodenum
|
||||
return result
|
||||
if self.time == other.time:
|
||||
return self.nodenum < other.nodenum
|
||||
else:
|
||||
return self.time < other.time
|
||||
|
||||
|
||||
class WayPointMobility(WirelessModel):
|
||||
|
|
17
daemon/tests/test_mobility.py
Normal file
17
daemon/tests/test_mobility.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
import pytest
|
||||
|
||||
from core.location.mobility import WayPoint
|
||||
|
||||
|
||||
class TestMobility:
|
||||
@pytest.mark.parametrize(
|
||||
"wp1, wp2, expected",
|
||||
[
|
||||
(WayPoint(10.0, 1, [0, 0], 1.0), WayPoint(1.0, 2, [0, 0], 1.0), False),
|
||||
(WayPoint(1.0, 1, [0, 0], 1.0), WayPoint(10.0, 2, [0, 0], 1.0), True),
|
||||
(WayPoint(1.0, 1, [0, 0], 1.0), WayPoint(1.0, 2, [0, 0], 1.0), True),
|
||||
(WayPoint(1.0, 2, [0, 0], 1.0), WayPoint(1.0, 1, [0, 0], 1.0), False),
|
||||
],
|
||||
)
|
||||
def test_waypoint_lessthan(self, wp1, wp2, expected):
|
||||
assert (wp1 < wp2) == expected
|
Loading…
Reference in a new issue