<commit_before># -*- coding: utf-8 -*-
import unittest

from babel.messages.extract import DEFAULT_KEYWORDS, extract

from babelvueextractor.extract import extract_vue
from babelvueextractor.tests.utils import FileMock


class TestMessagesExtractor(unittest.TestCase):
    def test_empty_template(self):
        template = FileMock("")
        result = extract_vue(template, DEFAULT_KEYWORDS.keys(), [], {})
        self.assertEqual(list(), list(result))

    def test_no_messages(self):
        template = FileMock("""
        <div>
            <h1>Foo</h1>
            <p>Lore ipsum delore ...</p>
        </div>
        """)
        result = extract_vue(template, DEFAULT_KEYWORDS.keys(), [], {})
        self.assertEqual(list(), list(result))

    def test_gettext(self):
        template = FileMock("""
        <div>
            {{ gettext('Foo') }}
        </div>
        """)
        result = extract_vue(template, DEFAULT_KEYWORDS.keys(), [], {})
        self.assertEqual(list(result), [
            (3, u'gettext', u"Foo", None)
        ])

    def test_underscore(self):
        template = FileMock("""
        <div>
            {{ _("Bar") }}
        </div>
        """)
        result = extract_vue(template, DEFAULT_KEYWORDS.keys(), [], {})
        self.assertEqual(list(result), [
            (3, '_', u'Bar', None)
        ])

    def test_babel(self):
        method = 'babelvueextractor.extract.extract_vue'
        fileobj = open('./templates/for_babel.vue')
        result = extract(method, fileobj)
        self.assertEqual(list(result), [
            (1, u'Привет123', None, None),
            (2, u'привет123', None, None)
        ])<commit_msg>fix path for test template<commit_after># -*- coding: utf-8 -*-
import unittest

from babel.messages.extract import DEFAULT_KEYWORDS, extract

from babelvueextractor.extract import extract_vue
from babelvueextractor.tests.utils import FileMock


class TestMessagesExtractor(unittest.TestCase):
    def test_empty_template(self):
        template = FileMock("")
        result = extract_vue(template, DEFAULT_KEYWORDS.keys(), [], {})
        self.assertEqual(list(), list(result))

    def test_no_messages(self):
        template = FileMock("""
        <div>
            <h1>Foo</h1>
            <p>Lore ipsum delore ...</p>
        </div>
        """)
        result = extract_vue(template, DEFAULT_KEYWORDS.keys(), [], {})
        self.assertEqual(list(), list(result))

    def test_gettext(self):
        template = FileMock("""
        <div>
            {{ gettext('Foo') }}
        </div>
        """)
        result = extract_vue(template, DEFAULT_KEYWORDS.keys(), [], {})
        self.assertEqual(list(result), [
            (3, u'gettext', u"Foo", None)
        ])

    def test_underscore(self):
        template = FileMock("""
        <div>
            {{ _("Bar") }}
        </div>
        """)
        result = extract_vue(template, DEFAULT_KEYWORDS.keys(), [], {})
        self.assertEqual(list(result), [
            (3, '_', u'Bar', None)
        ])

    def test_babel(self):
        method = 'babelvueextractor.extract.extract_vue'
        fileobj = open('babelvueextractor/tests/templates/for_babel.vue')
        result = extract(method, fileobj)
        self.assertEqual(list(result), [
            (1, u'Привет123', None, None),
            (2, u'привет123', None, None)
        ])
{'fraction_non_alphanumeric': 0.15197387948946275, 'fraction_numerical': 0.00771742356782428, 'mean_word_length': 2.3006856023506366, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '3300478', 'n_tokens_mistral': 1033, 'n_tokens_neox': 1011, 'n_words': 188}