<commit_before>import unittest

from hypothesis import given, assume
from hypothesis.strategies import text

from .. import adsbibtex


class Test_parse_config_file(unittest.TestCase):
    def test_parses_correct_file(self):
        document_list = ["# YAML front matter\n",
                         "cache_ttl: 24\n",
                         "cache_file:     adsbibtex.cache\n",
                         "bibtex_file:  test.tex",
                         "---\n",
                         "# Bibcode Name # Comment\n",
                         "2008Natur.452..329S Swain2008\n",
                         "2006AGUSM.A21A..06T # no name\n",
                         ]

        yaml_front_matter, bibcode_lines = adsbibtex.parse_config_file(document_list)

        yaml_front_matter_answer = ''.join(document_list[:4])
        bibcode_lines_answer = document_list[5:]

        self.assertEqual(yaml_front_matter, yaml_front_matter_answer)
        self.assertItemsEqual(bibcode_lines, bibcode_lines_answer)

    def test_raises_ADSBibtexConfigError_if_yaml_missing(self):
        document_list = ["cache_length: 24", "2006AGUSM.A21A..06T # no name\n"]

        with self.assertRaises(adsbibtex.ADSBibtexConfigError):
            adsbibtex.parse_config_file(document_list)

    def test_raises_ADSBibtexConfigError_if_empty(self):
        document_list = []

        with self.assertRaises(adsbibtex.ADSBibtexConfigError):
            adsbibtex.parse_config_file(document_list)


class Test_parse_bibcode_lines(unittest.TestCase):

    def test_parses_correctly(self):
        bibcode_list = ["# Bibcode Name # Comment\n",
                        "2008Natur.452..329S Swain2008",
                        "2006AGUSM.A21A..06T # no name\n",<commit_msg>fixed test due to moving of exceptions<commit_after>import unittest

from hypothesis import given, assume
from hypothesis.strategies import text

from .. import adsbibtex
from .. import adsbibtex_exceptions


class Test_parse_config_file(unittest.TestCase):
    def test_parses_correct_file(self):
        document_list = ["# YAML front matter\n",
                         "cache_ttl: 24\n",
                         "cache_file:     adsbibtex.cache\n",
                         "bibtex_file:  test.tex",
                         "---\n",
                         "# Bibcode Name # Comment\n",
                         "2008Natur.452..329S Swain2008\n",
                         "2006AGUSM.A21A..06T # no name\n",
                         ]

        yaml_front_matter, bibcode_lines = adsbibtex.parse_config_file(document_list)

        yaml_front_matter_answer = ''.join(document_list[:4])
        bibcode_lines_answer = document_list[5:]

        self.assertEqual(yaml_front_matter, yaml_front_matter_answer)
        self.assertItemsEqual(bibcode_lines, bibcode_lines_answer)

    def test_raises_ADSBibtexConfigError_if_yaml_missing(self):
        document_list = ["cache_length: 24", "2006AGUSM.A21A..06T # no name\n"]

        with self.assertRaises(adsbibtex_exceptions.ADSBibtexConfigError):
            adsbibtex.parse_config_file(document_list)

    def test_raises_ADSBibtexConfigError_if_empty(self):
        document_list = []

        with self.assertRaises(adsbibtex_exceptions.ADSBibtexConfigError):
            adsbibtex.parse_config_file(document_list)


class Test_parse_bibcode_lines(unittest.TestCase):

    def test_parses_correctly(self):
        bibcode_list = ["# Bibcode Name # Comment\n",
                        "2008Natur.452..329S Swain2008",
                        "2006AGUSM.A21A..06T # no name\n",
{'fraction_non_alphanumeric': 0.09001956947162426, 'fraction_numerical': 0.03242941012021247, 'mean_word_length': 2.303785780240074, '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': '798329', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1058, 'n_words': 164}