def test_move_backward(self, m_pc): """Move an object backward if delta is negative.""" o1 = OrderingListMixin() o2 = OrderingListMixin() o3 = OrderingListMixin() l = [o1, o2, o3] m_pc.return_value = l o3.move(-1) assert l == [o1, o3, o2] o2.move(-2) assert l == [o2, o1, o3]
def test_move_last_forward(self, m_pc): """Don't move last object if attempting to move forward.""" o1 = OrderingListMixin() o2 = OrderingListMixin() o3 = OrderingListMixin() l = [o1, o2, o3] m_pc.return_value = l o3.move(1) assert l == [o1, o2, o3] o3.move(42) assert l == [o1, o2, o3]
def test_move_past_last(self, m_pc): """Move object to end position if it would otherwise go past.""" o1 = OrderingListMixin() o2 = OrderingListMixin() o3 = OrderingListMixin() l = [o1, o2, o3] m_pc.return_value = l o1.move(3) assert l == [o2, o3, o1] o2.move(42) assert l == [o3, o1, o2]
def test_move_forward(self, m_pc): """Move an object forward in its parent collection.""" o1 = OrderingListMixin() o2 = OrderingListMixin() o3 = OrderingListMixin() l = [o1, o2, o3] m_pc.return_value = l o1.move(1) assert l == [o2, o1, o3] o2.move(2) assert l == [o1, o3, o2]
def test_move_first_backward(self, m_pc): """Don't move object backward if it's first.""" o1 = OrderingListMixin() o2 = OrderingListMixin() o3 = OrderingListMixin() l = [o1, o2, o3] m_pc.return_value = l o1.move(-1) assert l == [o1, o2, o3] o1.move(-42) assert l == [o1, o2, o3]
def test_move_before_beginning(self, m_pc): """Move object to first position if delta would put it before.""" o1 = OrderingListMixin() o2 = OrderingListMixin() o3 = OrderingListMixin() l = [o1, o2, o3] m_pc.return_value = l o3.move(-3) assert l == [o3, o1, o2] o2.move(-42) assert l == [o2, o3, o1]