def test_all_rectangles(self): a = Area(Rectangle(Field(0, 0), Field(127, 127)), 4) original = set() for i in range(0, 100): rect = Rectangle(Field(i, i), Field(i, i)) original.add(rect) a += rect result = a.all_rectangles() self.assertEqual(original, result)
def test_add_multiple_list(self): a = Area(Rectangle(Field(0, 0), Field(15, 15)), 1) rectangles = [ Rectangle(Field(2, 2), Field(3, 3)), Rectangle(Field(2, 5), Field(3, 5)), Rectangle(Field(5, 2), Field(6, 3)), Rectangle(Field(5, 5), Field(6, 6)) ] a += rectangles # Check self.assertEqual(set(rectangles), a.all_rectangles())
def test_all_rectangles_complex(self): a = Area(Rectangle(Field(0, 0), Field(511, 511)), 4) original = set() for i in range(1, 20): for j in range(1, 20): rect = (Rectangle(Field(i * 6, j * 6), Field(i * 6 + 2, j * 6 + 2))) original.add(rect) a += rect result = a.all_rectangles() self.assertEqual(original, result)
def gen_area(self): a = Area(Rectangle(Field(0, 0), Field(7, 7)), 1) rectangles = [ Rectangle(Field(2, 2), Field(3, 3), type=FieldType.inaccessible), Rectangle(Field(2, 5), Field(3, 6), type=FieldType.inaccessible), Rectangle(Field(5, 2), Field(6, 3), type=FieldType.inaccessible), Rectangle(Field(5, 5), Field(6, 6), type=FieldType.inaccessible) ] a.main.size = MagicMock(return_value=64) a.all_rectangles = MagicMock(return_value=set(rectangles)) a += rectangles # TODO: Mocking should work without this instruction return a