<commit_before><commit_msg>Add test for redis test helper<commit_after>import json

from twisted.trial.unittest import TestCase
from twisted.internet.defer import inlineCallbacks

from vumi_http_retry.tests.redis import create_client, zitems


class TestRedis(TestCase):
    @inlineCallbacks
    def setUp(self):
        self.redis = yield create_client()

    @inlineCallbacks
    def tearDown(self):
        yield self.redis.delete('foo')
        yield self.redis.transport.loseConnection()

    @inlineCallbacks
    def test_add_request(self):
        self.assertEqual((yield zitems(self.redis, 'foo')), [])

        yield self.redis.zadd('foo', 1, json.dumps({'bar': 23}))

        self.assertEqual((yield zitems(self.redis, 'foo')), [
            (1, {'bar': 23}),
        ])

        yield self.redis.zadd('foo', 2, json.dumps({'baz': 42}))

        self.assertEqual((yield zitems(self.redis, 'foo')), [
            (1, {'bar': 23}),
            (2, {'baz': 42}),
        ])
{'fraction_non_alphanumeric': 0.1469387755102041, 'fraction_numerical': 0.015306122448979591, 'mean_word_length': 2.9878048780487805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '803549', 'n_tokens_mistral': 333, 'n_tokens_neox': 308, 'n_words': 66}