test_group.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # jogai - Python Game Library
  2. #
  3. # This library is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU Library General Public
  5. # License as published by the Free Software Foundation; either
  6. # version 2 of the License, or (at your option) any later version.
  7. #
  8. # This library is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. # Library General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU Library General Public
  14. # License along with this library; if not, write to the Free
  15. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. #
  17. # Ramón Palleiro Rodríguez
  18. # Zero! Factorial Studio
  19. # info@zero.gal
  20. import pytest
  21. from jogai import *
  22. def test_random_group_with_amount_wrong_type(prepare_videogame):
  23. with pytest.raises(TypeError):
  24. RandomGroup(protagonist, 'foo', (0, 200), (0, 200))
  25. def test_random_group_with_ranges_wrong_type(prepare_videogame):
  26. with pytest.raises(TypeError):
  27. RandomGroup(protagonist, 2, 'bar', 'foo')
  28. def test_random_group_with_amount_not_greater_than_1(prepare_videogame):
  29. with pytest.raises(ValueError):
  30. RandomGroup(protagonist, -1, (0, 200), (0, 200))
  31. def test_random_group_with_wrong_length_ranges(prepare_videogame):
  32. with pytest.raises(ValueError):
  33. RandomGroup(protagonist, 3, (1, 2, 3), (1, 2, 3))
  34. def test_random_group_with_min_greater_than_max_range(prepare_videogame):
  35. with pytest.raises(ValueError):
  36. RandomGroup(protagonist, 3, (100, 3), (100, 3))
  37. def test_random_group_with_lists(prepare_videogame):
  38. RandomGroup(protagonist, 3, [0, 200], [0, 200])
  39. def test_rectangle_group_with_wrong_sides_type(prepare_videogame):
  40. with pytest.raises(TypeError):
  41. RectangleGroup(protagonist, 'foo', 'bar')
  42. def test_rectangle_group_with_sides_out_of_range(prepare_videogame):
  43. with pytest.raises(ValueError):
  44. RectangleGroup(protagonist, -1, 3)
  45. def test_rectangle_group_with_both_sides_equal_to_1(prepare_videogame):
  46. with pytest.raises(ValueError):
  47. RectangleGroup(protagonist, 1, 1)
  48. def test_square_group_with_wrong_side_type(prepare_videogame):
  49. with pytest.raises(TypeError):
  50. SquareGroup(protagonist, 'foo')
  51. def test_square_group_with_side_out_of_range(prepare_videogame):
  52. with pytest.raises(ValueError):
  53. SquareGroup(protagonist, -1)
  54. def test_stairs_group_with_wrong_steps_type(prepare_videogame):
  55. with pytest.raises(TypeError):
  56. StairsGroup(protagonist, 'foo')
  57. def test_stairs_group_with_steps_out_of_range(prepare_videogame):
  58. with pytest.raises(ValueError):
  59. StairsGroup(protagonist, -1)
  60. def test_stairs_group_with_horizontal_and_vertical_flip_wrong_type(
  61. prepare_videogame,
  62. ):
  63. with pytest.raises(TypeError):
  64. StairsGroup(protagonist, 3, 'foo', 'bar')