<commit_before>from __future__ import absolute_import

from django.utils.timezone import get_fixed_timezone, utc
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.timestamp import ceiling_to_hour, ceiling_to_day, \
    datetime_to_timestamp
from zerver.models import Realm, UserProfile, Client, get_realm, \
    get_user_profile_by_email

from analytics.lib.counts import CountStat, COUNT_STATS
from analytics.lib.time_utils import time_range
from analytics.models import RealmCount, UserCount, BaseCount, \
    FillState, last_successful_fill
from analytics.views import stats, get_chart_data, sort_by_totals, \
    sort_client_labels, rewrite_client_arrays

from datetime import datetime, timedelta
import mock
import ujson

from six.moves import range
from typing import List, Dict

class TestStatsEndpoint(ZulipTestCase):
    def test_stats(self):
        # type: () -> None
        self.user = get_user_profile_by_email('<EMAIL>')
        self.login(self.user.email)
        result = self.client_get('/stats')
        self.assertEqual(result.status_code, 200)
        # Check that we get something back
        self.assert_in_response("Zulip Analytics for", result)

class TestGetChartData(ZulipTestCase):
    maxDiff = None

    def setUp(self):
        # type: () -> None<commit_msg>mypy: Annotate maxDiff variable.<commit_after>from __future__ import absolute_import

from django.utils.timezone import get_fixed_timezone, utc
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.timestamp import ceiling_to_hour, ceiling_to_day, \
    datetime_to_timestamp
from zerver.models import Realm, UserProfile, Client, get_realm, \
    get_user_profile_by_email

from analytics.lib.counts import CountStat, COUNT_STATS
from analytics.lib.time_utils import time_range
from analytics.models import RealmCount, UserCount, BaseCount, \
    FillState, last_successful_fill
from analytics.views import stats, get_chart_data, sort_by_totals, \
    sort_client_labels, rewrite_client_arrays

from datetime import datetime, timedelta
import mock
import ujson

from six.moves import range
from typing import List, Dict

class TestStatsEndpoint(ZulipTestCase):
    def test_stats(self):
        # type: () -> None
        self.user = get_user_profile_by_email('<EMAIL>')
        self.login(self.user.email)
        result = self.client_get('/stats')
        self.assertEqual(result.status_code, 200)
        # Check that we get something back
        self.assert_in_response("Zulip Analytics for", result)

class TestGetChartData(ZulipTestCase):
    maxDiff = None  # type: int

    def setUp(self):
        # type: () -> None
{'fraction_non_alphanumeric': 0.07413010590015129, 'fraction_numerical': 0.0022692889561270802, 'mean_word_length': 4.365111561866126, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3194710', 'n_tokens_mistral': 809, 'n_tokens_neox': 785, 'n_words': 206}