示例#1
0
文件: tests.py 项目: jeffbuttars/ssmp
    def setUp(self):
        """todo: Docstring for setUp
        :return:
        :rtype:
        """
        self.rsq = RedisBasicQueue(default_q='rsq_test_q')
        self.rsq.remove()

        # Pump the Q
        self.msgs = []

        for m in ("A test message 1", "A test message 2",
                  "A test message 3", {'foo': "A test message 4",
                                       'bar': "blafdjafjds",
                                       'now': datetime.datetime.now()}):
            self.msgs.append(self.rsq.push(m))
示例#2
0
文件: tests.py 项目: jeffbuttars/ssmp
class TestRedisBasicQueue(unittest.TestCase):

    def setUp(self):
        """todo: Docstring for setUp
        :return:
        :rtype:
        """
        self.rsq = RedisBasicQueue(default_q='rsq_test_q')
        self.rsq.remove()

        # Pump the Q
        self.msgs = []

        for m in ("A test message 1", "A test message 2",
                  "A test message 3", {'foo': "A test message 4",
                                       'bar': "blafdjafjds",
                                       'now': datetime.datetime.now()}):
            self.msgs.append(self.rsq.push(m))
        # end for m in msgs
    #setUp()

    def test_one_item(self):
        """todo: Docstring for test_one_item
        :return:
        :rtype:
        """

        res = self.rsq.pop()
        exp = self.msgs.pop()

        self.assertEqual(res.ver, exp.ver)
        self.assertEqual(res.id, exp.id)
        self.assertEqual(res.fmt, exp.fmt)
        self.assertEqual(res.payload, exp.payload)
    #test_one_item()

    def test_all_items(self):
        for item in self.rsq.pops():
            print(item)
    #test_all_items()

    def test_some_items(self):
        for item in self.rsq.pops(num=2):
            print(item)