Fix portal type narrowing in zone tests
This commit is contained in:
parent
64c25b1025
commit
f418805b78
4 changed files with 13 additions and 12 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
|
from mudlib.portal import Portal
|
||||||
from mudlib.zones import load_zone
|
from mudlib.zones import load_zone
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -28,7 +29,7 @@ def test_hub_zone_has_portals():
|
||||||
zone = load_zone(hub_path)
|
zone = load_zone(hub_path)
|
||||||
|
|
||||||
# Find portals in zone contents
|
# Find portals in zone contents
|
||||||
portals = [obj for obj in zone._contents if obj.__class__.__name__ == "Portal"]
|
portals = [obj for obj in zone._contents if isinstance(obj, Portal)]
|
||||||
assert len(portals) == 3
|
assert len(portals) == 3
|
||||||
|
|
||||||
# Check that we have portals to each target zone
|
# Check that we have portals to each target zone
|
||||||
|
|
@ -43,7 +44,7 @@ def test_hub_zone_portals_at_correct_positions():
|
||||||
|
|
||||||
zone = load_zone(hub_path)
|
zone = load_zone(hub_path)
|
||||||
|
|
||||||
portals = [obj for obj in zone._contents if obj.__class__.__name__ == "Portal"]
|
portals = [obj for obj in zone._contents if isinstance(obj, Portal)]
|
||||||
|
|
||||||
# North portal to overworld at (7, 0)
|
# North portal to overworld at (7, 0)
|
||||||
overworld_portal = [p for p in portals if p.target_zone == "overworld"][0]
|
overworld_portal = [p for p in portals if p.target_zone == "overworld"][0]
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
|
from mudlib.portal import Portal
|
||||||
from mudlib.zones import load_zone
|
from mudlib.zones import load_zone
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -59,7 +60,7 @@ def test_flower_has_portal_to_treehouse():
|
||||||
zone = load_zone(flower_path)
|
zone = load_zone(flower_path)
|
||||||
|
|
||||||
# Find portals in zone contents
|
# Find portals in zone contents
|
||||||
portals = [obj for obj in zone._contents if obj.__class__.__name__ == "Portal"]
|
portals = [obj for obj in zone._contents if isinstance(obj, Portal)]
|
||||||
assert len(portals) == 1
|
assert len(portals) == 1
|
||||||
|
|
||||||
portal = portals[0]
|
portal = portals[0]
|
||||||
|
|
@ -93,7 +94,7 @@ def test_treehouse_has_portal_to_overworld():
|
||||||
zone = load_zone(treehouse_path)
|
zone = load_zone(treehouse_path)
|
||||||
|
|
||||||
# Find portals
|
# Find portals
|
||||||
portals = [obj for obj in zone._contents if obj.__class__.__name__ == "Portal"]
|
portals = [obj for obj in zone._contents if isinstance(obj, Portal)]
|
||||||
|
|
||||||
# Find the overworld portal
|
# Find the overworld portal
|
||||||
overworld_portals = [p for p in portals if p.target_zone == "overworld"]
|
overworld_portals = [p for p in portals if p.target_zone == "overworld"]
|
||||||
|
|
@ -113,7 +114,7 @@ def test_treehouse_has_portal_to_hub():
|
||||||
zone = load_zone(treehouse_path)
|
zone = load_zone(treehouse_path)
|
||||||
|
|
||||||
# Find portals
|
# Find portals
|
||||||
portals = [obj for obj in zone._contents if obj.__class__.__name__ == "Portal"]
|
portals = [obj for obj in zone._contents if isinstance(obj, Portal)]
|
||||||
|
|
||||||
# Find the hub portal
|
# Find the hub portal
|
||||||
hub_portals = [p for p in portals if p.target_zone == "hub"]
|
hub_portals = [p for p in portals if p.target_zone == "hub"]
|
||||||
|
|
|
||||||
|
|
@ -195,9 +195,7 @@ def test_export_zone_with_portals_round_trip():
|
||||||
assert loaded.height == zone.height
|
assert loaded.height == zone.height
|
||||||
|
|
||||||
# Verify portals were loaded correctly
|
# Verify portals were loaded correctly
|
||||||
portals = [
|
portals = [obj for obj in loaded._contents if isinstance(obj, Portal)]
|
||||||
obj for obj in loaded._contents if obj.__class__.__name__ == "Portal"
|
|
||||||
]
|
|
||||||
assert len(portals) == 2
|
assert len(portals) == 2
|
||||||
|
|
||||||
# Sort by y coordinate for consistent ordering
|
# Sort by y coordinate for consistent ordering
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
import pathlib
|
import pathlib
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
from mudlib.portal import Portal
|
||||||
from mudlib.zones import load_zone, load_zones
|
from mudlib.zones import load_zone, load_zones
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -254,7 +255,7 @@ label = "forest path"
|
||||||
zone = load_zone(temp_path)
|
zone = load_zone(temp_path)
|
||||||
|
|
||||||
# Find portals in zone contents
|
# Find portals in zone contents
|
||||||
portals = [obj for obj in zone._contents if obj.__class__.__name__ == "Portal"]
|
portals = [obj for obj in zone._contents if isinstance(obj, Portal)]
|
||||||
assert len(portals) == 2
|
assert len(portals) == 2
|
||||||
|
|
||||||
# Check first portal (tavern door at 5,3)
|
# Check first portal (tavern door at 5,3)
|
||||||
|
|
@ -307,7 +308,7 @@ rows = [
|
||||||
zone = load_zone(temp_path)
|
zone = load_zone(temp_path)
|
||||||
|
|
||||||
# Should have no portals
|
# Should have no portals
|
||||||
portals = [obj for obj in zone._contents if obj.__class__.__name__ == "Portal"]
|
portals = [obj for obj in zone._contents if isinstance(obj, Portal)]
|
||||||
assert len(portals) == 0
|
assert len(portals) == 0
|
||||||
finally:
|
finally:
|
||||||
temp_path.unlink()
|
temp_path.unlink()
|
||||||
|
|
@ -343,7 +344,7 @@ aliases = ["gateway", "gate", "portal"]
|
||||||
try:
|
try:
|
||||||
zone = load_zone(temp_path)
|
zone = load_zone(temp_path)
|
||||||
|
|
||||||
portals = [obj for obj in zone._contents if obj.__class__.__name__ == "Portal"]
|
portals = [obj for obj in zone._contents if isinstance(obj, Portal)]
|
||||||
assert len(portals) == 1
|
assert len(portals) == 1
|
||||||
|
|
||||||
portal = portals[0]
|
portal = portals[0]
|
||||||
|
|
@ -361,7 +362,7 @@ def test_tavern_has_portal_to_hub():
|
||||||
zone = load_zone(tavern_path)
|
zone = load_zone(tavern_path)
|
||||||
|
|
||||||
# Find portals in zone
|
# Find portals in zone
|
||||||
portals = [obj for obj in zone._contents if obj.__class__.__name__ == "Portal"]
|
portals = [obj for obj in zone._contents if isinstance(obj, Portal)]
|
||||||
assert len(portals) == 1
|
assert len(portals) == 1
|
||||||
|
|
||||||
# Check portal is at the door (4, 5) and leads to hub
|
# Check portal is at the door (4, 5) and leads to hub
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue