<commit_before>from unittest import TestCase

from wallace.interval_storage import IntervalStorage
from wallace.settings import AbstractSettings

class IntervalStorageTest(TestCase):
    def test_interval_storage_with_a_single_interval(self):
        interval_storage = IntervalStorage()
        self.assertFalse(interval_storage.has_intersection(0.0, 1.0))
        interval_storage.add_interval("1", 0.0, 1.0)

        self.assertEqual("1", interval_storage.get_entry(0.5))

        with self.assertRaises(ValueError):
            interval_storage.get_entry(1.5)

    def test_interval_storage_for_invalid_intervals(self):
        interval_storage = IntervalStorage()
        with self.assertRaises(ValueError):
            interval_storage.add_interval("1", 0.0, 1.2)

        with self.assertRaises(ValueError):
            interval_storage.add_interval("1", -3.2, 0.8)

        with self.assertRaises(ValueError):
            interval_storage.add_interval("1", -3.2, 1.4)

    def test_interval_storage_with_two_intervals_and_midpoint_get(self):
        interval_storage = IntervalStorage()
        interval_storage.add_interval("1", 0.0, 0.5)
        interval_storage.add_interval("2", 0.5, 1.0)

        self.assertEqual("1", interval_storage.get_entry(0.25))
        self.assertEqual("2", interval_storage.get_entry(0.5))
        self.assertEqual("2", interval_storage.get_entry(0.8))
<commit_msg>Adding an interval storage tests with three intervals.<commit_after>from unittest import TestCase

from wallace.interval_storage import IntervalStorage
from wallace.settings import AbstractSettings

class IntervalStorageTest(TestCase):
    def test_interval_storage_with_a_single_interval(self):
        interval_storage = IntervalStorage()
        self.assertFalse(interval_storage.has_intersection(0.0, 1.0))
        interval_storage.add_interval("1", 0.0, 1.0)

        self.assertEqual("1", interval_storage.get_entry(0.5))

        with self.assertRaises(ValueError):
            interval_storage.get_entry(1.5)

    def test_interval_storage_for_invalid_intervals(self):
        interval_storage = IntervalStorage()
        with self.assertRaises(ValueError):
            interval_storage.add_interval("1", 0.0, 1.2)

        with self.assertRaises(ValueError):
            interval_storage.add_interval("1", -3.2, 0.8)

        with self.assertRaises(ValueError):
            interval_storage.add_interval("1", -3.2, 1.4)

    def test_interval_storage_with_two_intervals_and_midpoint_get(self):
        interval_storage = IntervalStorage()
        interval_storage.add_interval("1", 0.0, 0.5)
        interval_storage.add_interval("2", 0.5, 1.0)

        self.assertEqual("1", interval_storage.get_entry(0.25))
        self.assertEqual("2", interval_storage.get_entry(0.5))
        self.assertEqual("2", interval_storage.get_entry(0.8))

    def test_interval_storage_with_three_intervals(self):
        interval_storage = IntervalStorage()
        interval_storage.add_interval("1", 0.0, 0.3)
        interval_storage.add_interval("2", 0.3, 0.6)
        interval_storage.add_interval("3", 0.6, 1.0)

        self.assertEqual("1", interval_storage.get_entry(0.0))
        self.assertEqual("1", interval_storage.get_entry(0.2))
        self.assertEqual("2", interval_storage.get_entry(0.3))
        self.assertEqual("2", interval_storage.get_entry(0.5))
        self.assertEqual("3", interval_storage.get_entry(0.6))
        self.assertEqual("3", interval_storage.get_entry(0.85))

        with self.assertRaises(ValueError):
            interval_storage.get_entry(1.0)

        with self.assertRaises(ValueError):
            interval_storage.get_entry(-0.01)
{'fraction_non_alphanumeric': 0.11250340506673931, 'fraction_numerical': 0.03731953146281667, 'mean_word_length': 3.59, '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': '1453134', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1120, 'n_words': 164}