<commit_before>from unittest import TestCase

from chartbeat import Chartbeat


class ChartbeatTest(TestCase):
    def setUp(self):
        self.beat = Chartbeat("<KEY>", "avc.com")
        self.keys = [
            Chartbeat.READ, Chartbeat.WRITE, Chartbeat.IDLE
        ]

    def test_histogram(self):
        data = self.beat.histogram(keys=self.keys, breaks=[1, 5, 10])
        for key in self.keys:
            self.assertTrue(key in data)

    def test_path_summary(self):
        data = self.beat.path_summary(keys=self.keys, types=["n", "n", "s"])
        for path in data:
            for key in self.keys:
                self.assertTrue(key in data[path])

    def test_quickstats(self):
        data = self.beat.quickstats(path="/")
        self.assertTrue("toprefs" in data)
        self.assertTrue("visit" in data)<commit_msg>added a test for api version<commit_after>from unittest import TestCase

from chartbeat import Chartbeat


class ChartbeatTest(TestCase):
    def setUp(self):
        self.beat = Chartbeat("<KEY>", "avc.com")
        self.keys = [
            Chartbeat.READ, Chartbeat.WRITE, Chartbeat.IDLE
        ]

    def test_histogram(self):
        data = self.beat.histogram(keys=self.keys, breaks=[1, 5, 10])
        for key in self.keys:
            self.assertTrue(key in data)

    def test_path_summary(self):
        data = self.beat.path_summary(keys=self.keys, types=["n", "n", "s"])
        for path in data:
            for key in self.keys:
                self.assertTrue(key in data[path])

    def test_quickstats(self):
        data = self.beat.quickstats(path="/")
        self.assertTrue("toprefs" in data)
        self.assertTrue("visit" in data)

    def test_api_version(self):
        self.beat = Chartbeat("317a25eccba186e0f6b558f45214c0e7", "avc.com", api_version='3')
        data = self.beat.quickstats(path="/")
        self.assertTrue("toprefs" in data)
        self.assertTrue("visit" in data)
{'fraction_non_alphanumeric': 0.12384851586489252, 'fraction_numerical': 0.014841351074718526, 'mean_word_length': 2.5545454545454547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5796661', 'n_tokens_mistral': 630, 'n_tokens_neox': 608, 'n_words': 140}