Skip to content

Commit

Permalink
Add test to ensure pre-populated players are linked to participant no…
Browse files Browse the repository at this point in the history
…des. The current implementation could cause issues if the node ids don't exactly match the imported player ids (e.g. a player drops out of the waiting room?). Not sure if that could ever happen in the real world though.
  • Loading branch information
alecpm committed Oct 13, 2023
1 parent 8dc7ca8 commit 63bf202
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/test_griduniverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,16 @@ def test_handle_connect_adds_player_to_grid(self, exp, a):
exp.handle_connect({"player_id": participant.id})
assert participant.id in exp.grid.players

def test_handle_connect_uses_existing_player_on_grid(self, exp, a):
participant = a.participant()
exp.grid.players[participant.id] = Player(
id=participant.id, color=[0.50, 0.86, 1.00], location=[10, 10]
)
exp.handle_connect({"player_id": participant.id})
assert participant.id in exp.node_by_player_id
assert len(exp.grid.players) == 1
assert len(exp.node_by_player_id) == 1

def test_handle_connect_is_noop_for_spectators(self, exp):
exp.handle_connect({"player_id": "spectator"})
assert exp.node_by_player_id == {}
Expand Down

0 comments on commit 63bf202

Please sign in to comment.