예제 #1
0
 def test_mutability_and_append(self):
     cubes = RedisList((1, 8, 27, 65, 125))
     cubes[3] = 64
     assert cubes == [1, 8, 27, 64, 125]
     cubes.append(216)
     cubes.append(7**3)
     assert cubes == [1, 8, 27, 64, 125, 216, 343]
예제 #2
0
 def test_mutability_and_append(self):
     cubes = RedisList((1, 8, 27, 65, 125))
     cubes[3] = 64
     assert cubes == [1, 8, 27, 64, 125]
     cubes.append(216)
     cubes.append(7**3)
     assert cubes == [1, 8, 27, 64, 125, 216, 343]
예제 #3
0
 def test_using_list_as_stack(self):
     stack = RedisList((3, 4, 5))
     stack.append(6)
     stack.append(7)
     assert stack == [3, 4, 5, 6, 7]
     assert stack.pop() == 7
     assert stack == [3, 4, 5, 6]
     assert stack.pop() == 6
     assert stack.pop() == 5
     assert stack == [3, 4]
예제 #4
0
 def test_using_list_as_stack(self):
     stack = RedisList((3, 4, 5))
     stack.append(6)
     stack.append(7)
     assert stack == [3, 4, 5, 6, 7]
     assert stack.pop() == 7
     assert stack == [3, 4, 5, 6]
     assert stack.pop() == 6
     assert stack.pop() == 5
     assert stack == [3, 4]
예제 #5
0
 def test_more_on_lists(self):
     a = RedisList((66.25, 333, 333, 1, 1234.5))
     assert (a.count(333), a.count(66.25), a.count('x')) == (2, 1, 0)
     a.insert(2, -1)
     a.append(333)
     assert a == [66.25, 333, -1, 333, 1, 1234.5, 333]
     assert a.index(333) == 1
     a.remove(333)
     assert a == [66.25, -1, 333, 1, 1234.5, 333]
     a.reverse()
     assert a == [333, 1234.5, 1, 333, -1, 66.25]
     a.sort()
     assert a == [-1, 1, 66.25, 333, 333, 1234.5]
     assert a.pop() == 1234.5
     assert a == [-1, 1, 66.25, 333, 333]
예제 #6
0
 def test_more_on_lists(self):
     a = RedisList((66.25, 333, 333, 1, 1234.5))
     assert (a.count(333), a.count(66.25), a.count('x')) == (2, 1, 0)
     a.insert(2, -1)
     a.append(333)
     assert a == [66.25, 333, -1, 333, 1, 1234.5, 333]
     assert a.index(333) == 1
     a.remove(333)
     assert a == [66.25, -1, 333, 1, 1234.5, 333]
     a.reverse()
     assert a == [333, 1234.5, 1, 333, -1, 66.25]
     a.sort()
     assert a == [-1, 1, 66.25, 333, 333, 1234.5]
     assert a.pop() == 1234.5
     assert a == [-1, 1, 66.25, 333, 333]