Пример #1
0
class RedisClientTestCase(unittest.TestCase):
    def setUp(self):
        self._conn = RedisClient()

    def tearDown(self):
        self._conn.flush()

    def test_put_and_pop(self):
        self._conn.put("label")
        assert self._conn.pop() == "label"

    def test_put_many(self):
        self._conn.put_many(['a', 'b'])
        assert self._conn.pop() == "a"
        assert self._conn.pop() == "b"

    def test_len(self):
        self._conn.put_many(['a', 'b', 'c'])
        assert self._conn.queue_len == 3

    def test_get(self):
        self._conn.put_many(['a', 'b', 'c', 'd'])
        _ = self._conn.get(2)
        assert self._conn.queue_len == 2