<commit_before># coding: utf-8
from __future__ import unicode_literals, division, print_function, absolute_import

from nose.tools import eq_
from marrow.wsgi.objects.request import LocalRequest
from redis import StrictRedis

from web.core.application import Application


def insert_data_controller(context):
    context.redis.set('bar', 'baz')


class TestMongoDBExtension(object):
    def setup(self):
        self.connection = StrictRedis(db='testdb')
        self.config = {
                'extensions': {
                        'redis': {
                                'connection': self.connection
                            }
                    }
            }

    def teardown(self):
        self.connection.flushdb()

    def test_data_insert(self):
        app = Application(insert_data_controller, self.config)
        request = LocalRequest()
        status, headers, body = app(request.environ)

        eq_(status, b'200 OK')
        eq_(self.connection['bar'], 'baz')
<commit_msg>Fixed test class name and made the test skippable if no Redis server is present.<commit_after># coding: utf-8
from __future__ import unicode_literals, division, print_function, absolute_import

from nose.tools import eq_
from nose.plugins.skip import SkipTest
from marrow.wsgi.objects.request import LocalRequest
from redis.exceptions import ConnectionError
from redis import StrictRedis

from web.core.application import Application


def insert_data_controller(context):
    context.redis.set('bar', 'baz')


class TestRedisExtension(object):
    def setup(self):
        self.connection = StrictRedis(db='testdb')
        try:
            self.connection.ping()
        except ConnectionError:
            raise SkipTest('No Redis server available')

        self.config = {
                'extensions': {
                        'redis': {
                                'connection': self.connection
                            }
                    }
            }

    def teardown(self):
        self.connection.flushdb()

    def test_data_insert(self):
        app = Application(insert_data_controller, self.config)
        request = LocalRequest()
        status, headers, body = app(request.environ)

        eq_(status, b'200 OK')
        eq_(self.connection['bar'], 'baz')

{'fraction_non_alphanumeric': 0.09075043630017451, 'fraction_numerical': 0.0034904013961605585, 'mean_word_length': 2.289813486370158, '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': '4210814', 'n_tokens_mistral': 628, 'n_tokens_neox': 594, 'n_words': 151}