<commit_before>"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".

Replace this with more appropriate tests for your application.
"""
from datetime import datetime
from mock import call, patch

try:  # pragma: no cover
    # Django 1.5
    from django.contrib.auth import get_user_model  # pragma: no cover
    User = get_user_model()  # pragma: no cover
except ImportError:  # pragma: no cover
    # Fallback for Django 1.4 (or lower)
    from django.contrib.auth.models import User  # pragma: no cover
from django.core.urlresolvers import reverse
from django.test import TestCase, Client
from django.test.utils import override_settings


@override_settings(REDIS_METRICS_HOST='localhost')
@override_settings(REDIS_METRICS_PORT=6379)
@override_settings(REDIS_METRICS_DB=0)
@override_settings(REDIS_METRICS_PASSWORD=None)
@override_settings(REDIS_METRICS_SOCKET_TIMEOUT=None)
@override_settings(REDIS_METRICS_SOCKET_CONNECTION_POOL=None)
@override_settings(REDIS_METRICS_MIN_GRANULARITY='seconds')
@override_settings(REDIS_METRICS_MAX_GRANULARITY='yearly')
class TestViews(TestCase):
    url = 'redis_metrics.urls'

    def setUp(self):
        # Patch the connection to redis, but keep a reference to the
        # created StrictRedis instance, so we can make assertions about how
        # it's called.
        self.redis_patcher = patch('redis_metrics.models.redis.StrictRedis')
        mock_StrictRedis = self.redis_patcher.start()
        self.redis = mock_StrictRedis.return_value

        self.user = User.objects.create_superuser(
            username="redis_metrics_test_user",
            email="<EMAIL>",
            password="<PASSWORD>"<commit_msg>Stackoverflow says don't do this at the module level anymore :-/<commit_after>"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".

Replace this with more appropriate tests for your application.
"""
from datetime import datetime
from mock import call, patch

from django.core.urlresolvers import reverse
from django.test import TestCase, Client
from django.test.utils import override_settings


@override_settings(REDIS_METRICS_HOST='localhost')
@override_settings(REDIS_METRICS_PORT=6379)
@override_settings(REDIS_METRICS_DB=0)
@override_settings(REDIS_METRICS_PASSWORD=None)
@override_settings(REDIS_METRICS_SOCKET_TIMEOUT=None)
@override_settings(REDIS_METRICS_SOCKET_CONNECTION_POOL=None)
@override_settings(REDIS_METRICS_MIN_GRANULARITY='seconds')
@override_settings(REDIS_METRICS_MAX_GRANULARITY='yearly')
class TestViews(TestCase):
    url = 'redis_metrics.urls'

    def _get_user_model(self):
        try:  # pragma: no cover
            # Django >= 1.5
            from django.contrib.auth import get_user_model  # pragma: no cover
            User = get_user_model()  # pragma: no cover
        except ImportError:  # pragma: no cover
            # Fallback for Django 1.4 (or lower)
            from django.contrib.auth.models import User  # pragma: no cover
        return User

    def setUp(self):
        # Patch the connection to redis, but keep a reference to the
        # created StrictRedis instance, so we can make assertions about how
        # it's called.
        self.redis_patcher = patch('redis_metrics.models.redis.StrictRedis')
        mock_StrictRedis = self.redis_patcher.start()
        self.redis = mock_StrictRedis.return_value

        User = self._get_user_model()
        self.user = User.objects.create_superuser(
            username="redis_metrics_test_user",
            email="<EMAIL>",
            password="<PASSWORD>"
{'fraction_non_alphanumeric': 0.08027397260273973, 'fraction_numerical': 0.004931506849315068, 'mean_word_length': 4.092050209205021, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, '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': '2956049', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1100, 'n_words': 281}