Skip to content
Snippets Groups Projects
Commit 70a61b45 authored by Florian Schröder's avatar Florian Schröder
Browse files

Add pygame tests

This commit introduces a new test suite for the pygame functionality. It includes tests for color formatting and uniqueness, angle calculations, and proper initialization of the Visualizer. The tests aim to enhance game integrity and avoid potential issues with visualization.
parent 0ddb9e04
Branches
Tags
1 merge request!79Resolve "More tests"
import yaml
from cooperative_cuisine import ROOT_DIR
from cooperative_cuisine.pygame_2d_vis.drawing import calc_angle, Visualizer
from cooperative_cuisine.pygame_2d_vis.game_colors import RGB, WHITE, colors
def test_colors():
assert RGB(red=255, green=255, blue=255).hex_format() == "#FFFFFF"
assert WHITE.hex_format() == "#FFFFFF"
assert len(colors) >= 552
def test_calc_angle():
assert calc_angle([0.0, 1.0], [1.0, 0.0]) == -90.0
assert calc_angle([1.0, 1.0], [1.0, -1.0]) == -90.0
def test_visualizer():
with open(ROOT_DIR / "pygame_2d_vis" / "visualization.yaml", "r") as file:
visualization_config = yaml.safe_load(file)
vis = Visualizer(visualization_config)
vis.create_player_colors(10)
assert len(vis.player_colors) >= 10
assert len(set(vis.player_colors)) >= 10
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment