コード例 #1
0
 def test_move_after_last(self, m_pc):
     """Move obj to last position if other is last."""
     o1 = OrderingListMixin()
     o2 = OrderingListMixin()
     o3 = OrderingListMixin()
     l = [o1, o2, o3]
     m_pc.return_value = l
     o1.move_after(o3)
     assert l == [o2, o3, o1]
コード例 #2
0
 def test_move_after_backwards(self, m_pc):
     """Move obj to position after other if other is before obj."""
     o1 = OrderingListMixin()
     o2 = OrderingListMixin()
     o3 = OrderingListMixin()
     l = [o1, o2, o3]
     m_pc.return_value = l
     o3.move_after(o1)
     assert l == [o1, o3, o2]
コード例 #3
0
 def test_move_after_forwards(self, m_pc):
     """Move obj to position after other if other is after obj."""
     o1 = OrderingListMixin()
     o2 = OrderingListMixin()
     o3 = OrderingListMixin()
     l = [o1, o2, o3]
     m_pc.return_value = l
     o1.move_after(o2)
     assert l == [o2, o1, o3]
コード例 #4
0
 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]
コード例 #5
0
 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]
コード例 #6
0
 def test_move_after_self(self, m_pc):
     """Keep order the same if for some reason other is self."""
     o1 = OrderingListMixin()
     o2 = OrderingListMixin()
     o3 = OrderingListMixin()
     l = [o1, o2, o3]
     m_pc.return_value = l
     o1.move_after(o1)
     assert l == [o1, o2, o3]
     o2.move_after(o2)
     assert l == [o1, o2, o3]
     o3.move_after(o3)
     assert l == [o1, o2, o3]
コード例 #7
0
 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]
コード例 #8
0
 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]
コード例 #9
0
 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]
コード例 #10
0
 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]