-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_crazy_maze.py
40 lines (33 loc) · 1.32 KB
/
test_crazy_maze.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
import unittest
from io import StringIO
from unittest.mock import patch
import sys
from maze import crazy_maze as obstacles
class MyTest(unittest.TestCase):
def test_get_obstacles(self):
result = obstacles.get_obstacles()
self.assertEqual(len(result) > 0, True)
def test_randomly_populate_pixel(self):
result = obstacles.randomly_populate_pixel(0,0)
self.assertEqual(len(result) > 0, True)
def test_is_position_blocked(self):
obstacles.random.randint = lambda a,b : 1
obstacles.get_obstacles()
result = obstacles.is_position_blocked(1,1)
self.assertEqual(result, False)
result = obstacles.is_position_blocked(1,10)
self.assertEqual(result, False)
def test_is_path_blocked(self):
obstacles.random.randint = lambda a,b : 1
obstacles.get_obstacles()
result = obstacles.is_path_blocked(1, 0, 1, 5)
self.assertEqual(result, False)
result = obstacles.is_path_blocked(10,10, 10, 20)
self.assertEqual(result, False)
def test_check_greater(self):
value1 = 1
value2 = 5
result = obstacles.check_greater(value1, value2)
self.assertEqual(result, (value1, value2))
result = obstacles.check_greater(value2, value1)
self.assertEqual(result, (value1, value2))