<commit_before>from base_test import BaseTest


class TestNote(BaseTest):
    def test_render_html(self):
        """
        Tests that render_html returns valid HTML
        """
        self.test_note.text = "# Test"
        self.test_note._generate_html()
        self.assertEquals(
            self.test_note.html, "<h1>Test</h1>")

    def test_increment_love_count_default(self):
        """
        Tests that increment_love_count increments the love_count by 1
        by default
        """
        self.test_note.increment_love_count()
        self.test_note.save()
        self.assertEquals(self.test_note.love_count, 1)

    def test_increment_love_count_custom(self):
        """
        Tests that increment_love_count increments the love_count by
        our custom factor
        """
        self.test_note.increment_love_count(9)
        self.test_note.save()
        self.assertEquals(self.test_note.love_count, 9)

    def test_generate_description_short(self):
        """
        Tests that a short note has a description with no
        trailing '...'
        """
        self.test_note.text = "# Hello World 👋"
        self.test_note.save()
        self.assertEquals(
            self.test_note.description, "Hello World 👋"
        )

    def test_generate_description_long(self):
        """
        Tests that a long note has a description with a
        trailing '...'
        """
        self.test_note.text = "word " * 100
        self.test_note.save()
        self.assertEquals(
            self.test_note.description, ("word " * 50)[:-1] + "..."
        )

    def test_save_empty_note(self):
        """
        Tests that an note can be created without text
        """
        self.test_note.text = ""
        self.test_note.save()

    def test_generate_share_handle(self):
        """
        Tests that the Note slug generator works
        """
        self.assertEquals(
            len(self.test_note.slug),
            7
        )
<commit_msg>Adds testing for empty loc notes<commit_after>from base_test import BaseTest

from models.note import Note


class TestNote(BaseTest):
    def test_render_html(self):
        """
        Tests that render_html returns valid HTML
        """
        self.test_note.text = "# Test"
        self.test_note._generate_html()
        self.assertEquals(
            self.test_note.html, "<h1>Test</h1>")

    def test_increment_love_count_default(self):
        """
        Tests that increment_love_count increments the love_count by 1
        by default
        """
        self.test_note.increment_love_count()
        self.test_note.save()
        self.assertEquals(self.test_note.love_count, 1)

    def test_increment_love_count_custom(self):
        """
        Tests that increment_love_count increments the love_count by
        our custom factor
        """
        self.test_note.increment_love_count(9)
        self.test_note.save()
        self.assertEquals(self.test_note.love_count, 9)

    def test_generate_description_short(self):
        """
        Tests that a short note has a description with no
        trailing '...'
        """
        self.test_note.text = "# Hello World 👋"
        self.test_note.save()
        self.assertEquals(
            self.test_note.description, "Hello World 👋"
        )

    def test_generate_description_long(self):
        """
        Tests that a long note has a description with a
        trailing '...'
        """
        self.test_note.text = "word " * 100
        self.test_note.save()
        self.assertEquals(
            self.test_note.description, ("word " * 50)[:-1] + "..."
        )

    def test_save_empty_note(self):
        """
        Tests that an note can be created without text
        """
        self.test_note.text = ""
        self.test_note.save()

    def test_generate_share_handle(self):
        """
        Tests that the Note slug generator works
        """
        self.assertEquals(
            len(self.test_note.slug),
            7
        )

    def test_empty_location(self):
        """
        Tests that a Note object can be created without a location
        """
        try:
            test_note = Note()
            test_note.save()
        except Exception as e:
            self.fail(e)

{'fraction_non_alphanumeric': 0.09768095572733661, 'fraction_numerical': 0.006090419301944249, 'mean_word_length': 1.9246575342465753, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6094378', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1203, 'n_words': 273}