def test_basic_usage(self): d = RedisDeque('ghi', redis=self.redis) assert d == ['g', 'h', 'i'] d.append('j') d.appendleft('f') assert d == ['f', 'g', 'h', 'i', 'j'] assert d.pop() == 'j' assert d.popleft() == 'f' assert d == ['g', 'h', 'i'] assert d[0] == 'g' assert d[-1] == 'i' assert list(reversed(d)) == ['i', 'h', 'g'] assert 'h' in d d.extend('jkl') assert d == ['g', 'h', 'i', 'j', 'k', 'l'] d.rotate(1) assert d == ['l', 'g', 'h', 'i', 'j', 'k'] d.rotate(-1) assert d == ['g', 'h', 'i', 'j', 'k', 'l'] assert RedisDeque(reversed(d), redis=self.redis) == ['l', 'k', 'j', 'i', 'h', 'g'] d.clear() with self.assertRaises(IndexError): d.pop() d.extendleft('abc') assert d == ['c', 'b', 'a']
def test_popleft_from_empty(self): d = RedisDeque(redis=self.redis) with self.assertRaises(IndexError): d.popleft()