Ejemplo n.º 1
0
 def test_squares_should_be_equal_with_same_coords_different_state(self):
     square_a = Square(x=5, y=2)
     square_b = Square(x=5, y=2)
     square_b.flip()
     self.assertTrue(square_a == square_b,
                     "Squares with equal coordinates should be equal even "
                     "with different activated states")
Ejemplo n.º 2
0
 def test_ant_get_current_activation_returns_true_if_square_activated(self):
     ant = AntGrid()
     ant.x, ant.y = 1, 3
     square_1_3 = Square(x=1, y=3)
     square_1_3.activated = True
     ant.grid_list = [square_1_3]
     self.assertEqual(True, ant.current_activation())
Ejemplo n.º 3
0
 def test_ant_get_current_activation_returns_true_if_square_activated(self):
     ant = AntGrid()
     ant.x, ant.y = 1, 3
     square_1_3 = Square(x=1, y=3)
     square_1_3.activated = True
     ant.grid_list = [square_1_3]
     self.assertEqual(True, ant.current_activation())
Ejemplo n.º 4
0
 def test_squares_should_be_equal_with_same_coords_different_state(self):
     square_a = Square(x=5, y=2)
     square_b = Square(x=5, y=2)
     square_b.flip()
     self.assertTrue(
         square_a == square_b,
         "Squares with equal coordinates should be equal even "
         "with different activated states")
Ejemplo n.º 5
0
 def test_ant_get_current_activation_returns_state_of_correct_square(self):
     ant = AntGrid()
     ant.x, ant.y = 3, 4
     square_0_0 = Square(x=0, y=0)
     square_0_1 = Square(x=0, y=1)
     square_3_4 = Square(x=3, y=4)
     square_3_4.activated = True
     ant.grid_list = [square_0_0, square_0_1, square_3_4]
     self.assertEqual(True, ant.current_activation())
Ejemplo n.º 6
0
 def test_ant_get_current_activation_returns_state_of_correct_square(self):
     ant = AntGrid()
     ant.x, ant.y = 3, 4
     square_0_0 = Square(x=0, y=0)
     square_0_1 = Square(x=0, y=1)
     square_3_4 = Square(x=3, y=4)
     square_3_4.activated = True
     ant.grid_list = [square_0_0, square_0_1, square_3_4]
     self.assertEqual(True, ant.current_activation())
Ejemplo n.º 7
0
 def test_squares_unequal_if_different_coordinates(self):
     square_a = Square(x=5, y=2)
     square_b = Square(x=5, y=7)
     self.assertFalse(square_a == square_b,
                      "Square with uneqal coordinates should not be equal")
Ejemplo n.º 8
0
 def test_square_starts_unactivated(self):
     square = Square(x=0, y=4)
     self.assertEqual(False, square.activated)
Ejemplo n.º 9
0
 def test_square_equal_to_other_square_object_with_same_coords(self):
     square_a = Square(x=5, y=2)
     square_b = Square(x=5, y=2)
     self.assertTrue(square_a == square_b,
                     "Squares with equal coordinates should be equal")
Ejemplo n.º 10
0
 def test_different_squares_have_different_hashes(self):
     square_a = Square(x=1, y=3)
     square_b = Square(x=2, y=7)
     self.assertNotEqual(hash(square_a), hash(square_b))
Ejemplo n.º 11
0
 def __init__(self):
     self.x = 0
     self.y = 0
     self.dir = "up"
     self.grid_list = [Square(x=0, y=0)]
Ejemplo n.º 12
0
 def test_square_hash_does_not_reflect_activation(self):
     square_a = Square(x=2, y=3)
     square_b = Square(x=2, y=3)
     square_b.flip()
     self.assertEqual(hash(square_a), hash(square_b))
Ejemplo n.º 13
0
 def test_square_flip_function_flips_activated_property(self):
     square = Square(x=0, y=0)
     square.flip()
     self.assertEqual(True, square.activated)
Ejemplo n.º 14
0
 def test_square_flipping_twice_leaves_same_activated_property(self):
     square = Square(x=0, y=0)
     square.flip()
     square.flip()
     self.assertEqual(False, square.activated)
Ejemplo n.º 15
0
 def test_square_flip_function_flips_activated_property(self):
     square = Square(x=0, y=0)
     square.flip()
     self.assertEqual(True, square.activated)
Ejemplo n.º 16
0
 def test_square_starts_with_correct_y_value(self):
     square = Square(x=2, y=-4)
     self.assertEqual(-4, square.y)
Ejemplo n.º 17
0
 def test_ant_get_current_activation_returns_false_at_origin(self):
     ant = AntGrid()
     ant.x, ant.y = 0, 0
     ant.grid_list = [Square(x=0, y=0)]
     self.assertEqual(False, ant.current_activation())
Ejemplo n.º 18
0
 def test_ant_grid_contains_0_0_square(self):
     ant = AntGrid()
     self.assertIn(Square(x=0, y=0), ant.grid_list)
Ejemplo n.º 19
0
 def test_square_starts_with_correct_x_value(self):
     square = Square(x=5, y=23)
     self.assertEqual(5, square.x)
Ejemplo n.º 20
0
 def test_square_hash_reflect_x_and_y_variation1(self):
     square = Square(x=3, y=20)
     self.assertEqual(hash((3, 20)), hash(square))
Ejemplo n.º 21
0
 def test_square_flipping_twice_leaves_same_activated_property(self):
     square = Square(x=0, y=0)
     square.flip()
     square.flip()
     self.assertEqual(False, square.activated)
Ejemplo n.º 22
0
 def test_square_hash_does_not_reflect_activation(self):
     square_a = Square(x=2, y=3)
     square_b = Square(x=2, y=3)
     square_b.flip()
     self.assertEqual(hash(square_a), hash(square_b))
Ejemplo n.º 23
0
 def test_square_hash_reflect_x_and_y_variation2(self):
     square = Square(x=-10, y=2)
     self.assertEqual(hash((-10, 2)), hash(square))
Ejemplo n.º 24
0
 def current_activation(self):
     for square in self.grid_list:
         if square == Square(x=self.x, y=self.y):
             return square.activated