Skip to content

Commit

Permalink
test: landscape module
Browse files Browse the repository at this point in the history
  • Loading branch information
u8slvn committed Aug 20, 2024
1 parent a591994 commit d063327
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ def pygame():
yield

pg.quit()


@pytest.fixture
def pg_screen_mock(mocker):
"""Mock the pygame screen surface."""

return mocker.Mock(spec=pg.Surface, instance=True)
22 changes: 22 additions & 0 deletions tests/test_landscape.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from __future__ import annotations

from doggo.landscape import Biome
from doggo.landscape import LandscapeLayer


def test_get_random_biome():
biome = Biome.random()

assert isinstance(biome, Biome)
assert biome in list(Biome)


def test_landscape_layer_draw_on_screen(pg_screen_mock):
image = f"{Biome.MOUNTAIN:02d}_bg.png"
landscape_layer = LandscapeLayer(image=image)

landscape_layer.draw(pg_screen_mock)

pg_screen_mock.blit.assert_called_once_with(
landscape_layer.image, landscape_layer.rect
)

0 comments on commit d063327

Please sign in to comment.