コード例 #1
0
    def test_rank_sets_by_cardinality(self):
        cardinalities = (61., 60., 5., 4., 3., 2., 1.)
        _keys = [("l%d" % card) for card in cardinalities]
        keys_with_cardinalities = zip(_keys, cardinalities)
        sets = [
            hot_redis.Set(range(int(card)), key=key)
            for key, card
            in keys_with_cardinalities
        ]
        client = hot_redis.default_client()

        calls = [
            (lambda i: [x for x in i], 'iter'),
            (lambda i: i[:], '[:]'),
            (lambda i: i[3:4], '[3:4]'),
            (lambda i: i[-4:3], '[-4:3]'),
            (lambda i: i[2:], '[2:]'),
            (lambda i: i[:2], '[:2]'),
            #empty),
            (lambda i: i[2:1], '[2:1]'),
            (lambda i: i[-1:-2], '[-1:-2]')
        ]

        for call, code in calls:
            expected = call(keys_with_cardinalities)
            result = call(client.rank_sets_by_cardinality(*_keys))
            self.assertEquals(
                result,
                expected,
                "Results not equal when called with call={code}, "
                "got result={result}, expected={expected}".format(
                    code=code, result=result,
                    expected=expected
                )
            )

        with self.assertRaises(ValueError):
            client.rank_lists_by_length('only_one_key'),
コード例 #2
0
 def tearDown(self):
     client = hot_redis.default_client()
     while keys:
         client.delete(keys.pop())
コード例 #3
0
ファイル: tests.py プロジェクト: vBoqin/hot-redis
 def tearDown(self):
     client = hot_redis.default_client()
     while keys:
         client.delete(keys.pop())