def test_height_and_width(self): op1 = self.FakeOp(-100, 50) op2 = self.FakeOp(100, 400) op3 = self.FakeOp(300, 700) ops = [op1, op2, op3] layout = PlannerLayout() for op in ops: layout._add_operation(op) assert layout.height == 650 assert layout.width == 400
def test_xy(self): op1 = self.FakeOp(0, 50) op2 = self.FakeOp(100, 400) op3 = self.FakeOp(300, 700) ops = [op1, op2, op3] layout = PlannerLayout() for op in ops: layout._add_operation(op) assert layout.x == 0 assert layout.y == 50 assert layout.xy == (0, 50)
def test_midpoint_of_ops(self): op1 = self.FakeOp(-100, 50) op2 = self.FakeOp(100, 400) op3 = self.FakeOp(300, 700) ops = [op1, op2, op3] layout = PlannerLayout() for op in ops: layout._add_operation(op) x, y = layout.midpoint() assert x == 100, "Should 100" assert y == (700 - 50) / 2.0 + 50
def test_bounds_of_ops(self): op1 = self.FakeOp(300, 50) op2 = self.FakeOp(100, 400) op3 = self.FakeOp(0, 700) ops = [op1, op2, op3] layout = PlannerLayout() for op in ops: layout._add_operation(op) ul, lr = layout.bounds() assert ul == (0, 50) assert lr == (300, 700)
def test_y_setter(self): op1 = self.FakeOp(0, 50) op2 = self.FakeOp(100, 400) op3 = self.FakeOp(300, 700) ops = [op1, op2, op3] layout = PlannerLayout() for op in ops: layout._add_operation(op) layout.y = 0 assert layout.y == 0 assert op1.y == 0 assert op2.y == 350 assert op3.y == 650
def test_x_setter(self): op1 = self.FakeOp(0, 50) op2 = self.FakeOp(100, 400) op3 = self.FakeOp(300, 700) ops = [op1, op2, op3] layout = PlannerLayout() for op in ops: layout._add_operation(op) layout.x = 75 assert layout.x == 75 assert op1.x == 75 assert op2.x == 175 assert op3.x == 375
def test_translate_ops(self): op1 = self.FakeOp(0, 50) op2 = self.FakeOp(100, 400) op3 = self.FakeOp(300, 700) ops = [op1, op2, op3] layout = PlannerLayout() for op in ops: layout._add_operation(op) layout.translate(-10, 30) assert op1.x == -10 assert op2.y == 430
def test_move(self): op1 = self.FakeOp(0, 50) op2 = self.FakeOp(100, 400) op3 = self.FakeOp(300, 700) ops = [op1, op2, op3] layout = PlannerLayout() for op in ops: layout._add_operation(op) layout.move(100, 100) assert op1.x == 100 assert op2.x == 200 assert op3.x == 400 assert op1.y == 100 assert op2.y == 450 assert op3.y == 750