def test_messages_get_world_data(): game = Game() player = Player(x=1, y=1, player_id=0) game.alive_players = [player] game.npcs = [NPC(2, 2)] game.bullets = [Bullet(3, 3)] game.walls = [TinyWall(x=4, y=4), Water(x=5, y=5)] game.coins = [Coin(x=4, y=4), Coin(x=5, y=5)] assert messages.get_world_data(player, game) == dict( id=player.id.hex, cords=[ dict(type='player', id=player.id.hex, position={ 'x': 1, 'y': 1 }), dict(type='npc', id=game.npcs[0].id.hex, position={ 'x': 2, 'y': 2 }), dict(type='bullet', id=game.bullets[0].id.hex, position={ 'x': 3, 'y': 3 }), dict(type='tinywall', id=game.walls[0].id.hex, position={ 'x': 4, 'y': 4 }), dict(type='water', id=game.walls[1].id.hex, position={ 'x': 5, 'y': 5 }), dict(type='coin', id=game.coins[0].id.hex, position={ 'x': 4, 'y': 4 }), dict(type='coin', id=game.coins[1].id.hex, position={ 'x': 5, 'y': 5 }), ])
def test_render_walls(pygame): game = Game() game.walls = [ TinyWall(48, 32), Metal(64, 48), Water(96, 32), ] surface = Mock(spec=Surface) drawer = Drawer(game) os = Drawer.OFFSET drawer.WALLS = { # pygame surface can't use eq operator ;_; TinyWall: 'tiny_wall', Metal: 'metal', Water: 'water', } drawer._render_walls(surface) assert surface.blit.call_args_list == [ call('tiny_wall', (os + 48, os + 32), (16, 0, 8, 8)), call('metal', (os + 64, os + 48), (0, 16, 32, 32)), call('water', (os + 96, os + 32), (0, 0, 32, 32)), ]