-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
144 lines (108 loc) · 3.76 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
"""This module includes the fixtures used in the code tests."""
from typing import List, Tuple
import pygame
import pytest
from core.utils.dinosaur import Dinosaur, Monster
from core.utils.game import Game
from core.utils.laser import Laser
from core.utils.robot import Robot
@pytest.fixture(scope="session")
def surface_dimensions() -> Tuple[int, int]:
"""This fixture defines the surface dimensions used for tests."""
dimensions = (6, 12)
return dimensions
@pytest.fixture(scope="session")
def screen_height() -> int:
"""This fixture defines the height of the screen used for tests."""
height = 100
return height
@pytest.fixture(scope="session")
def screen_width() -> int:
"""This fixture defines the width of the screen used for tests."""
width = 100
return width
@pytest.fixture(scope="session")
def screen(screen_width: int, screen_height: int) -> pygame.display:
"""This fixture defines the screen used for tests."""
test_screen = pygame.display.set_mode((screen_width, screen_height))
return test_screen
@pytest.fixture(scope="session")
def test_shape(screen_width: int, screen_height: int) -> List[str]:
"""This fixture defines the shape used for tests to create blocks"""
shape = [
" xx",
" x",
]
return shape
@pytest.fixture(scope="session")
def laser_position() -> Tuple[int, int]:
"""This fixture defines the laser position used for tests."""
pos = (10, 20)
return pos
@pytest.fixture(scope="session")
def test_image(surface_dimensions: Tuple[int, int]) -> pygame.Surface:
"""This fixture defines an input image used for tests."""
image = pygame.Surface(surface_dimensions)
image.fill("white")
return image
@pytest.fixture(scope="session")
def laser_object(
surface_dimensions: Tuple[int, int],
laser_position: Tuple[int, int],
screen_height: int,
) -> Laser:
"""This fixture instatiates the Laser class used for tests."""
laser = Laser(
pos=laser_position,
screen_height=screen_height,
speed=5,
surface_dimensions=surface_dimensions,
)
return laser
@pytest.fixture(scope="session")
def game_object(
screen: pygame.display,
screen_width: int,
screen_height: int,
moving_dinosaurs: int = 0,
) -> Game:
"""This fixture instatiates the Laser class used for tests."""
game = Game(
screen=screen,
screen_width=screen_width,
screen_height=screen_height,
moving_dinosaurs=moving_dinosaurs,
number_of_dinosaur_rows=3,
number_of_dinosaur_cols=3,
obstacle_amount=4,
)
return game
@pytest.fixture(scope="session")
def dinosaur_object(
screen: pygame.display, color: str = "red", x: int = 10, y: int = 20
) -> Dinosaur:
"""This fixture instatiates the Dinosaur class used for tests."""
dinosaur = Dinosaur(screen=screen, color=color, x=x, y=y)
return dinosaur
@pytest.fixture(scope="session")
def monster_object(screen: pygame.display, screen_width: int) -> Monster:
"""This fixture instatiates the Monster class used for tests."""
monster = Monster(screen=screen, side="right", screen_width=screen_width)
return monster
@pytest.fixture(scope="session")
def robot_position(screen_width: int, screen_height: int) -> Tuple[float, int]:
"""This fixture defines the robot position used for tests."""
pos = (screen_width / 2, screen_height)
return pos
@pytest.fixture(scope="session")
def robot_object(
screen: pygame.display,
robot_position: Tuple[int, int],
screen_height: int,
speed: int = 5,
) -> Robot:
"""This fixture instatiates the Robot class used for tests."""
test_robot = Robot(
screen=screen, pos=robot_position, constraint=screen_height, speed=speed
)
return test_robot