<commit_before># -*- coding: utf-8 -*-
from django.forms import ValidationError

from djangosanetesting.cases import UnitTestCase, DatabaseTestCase

from djangomarkup.fields import RichTextField, post_save_listener
from djangomarkup.models import SourceText

from exampleapp.models import Article

class TestRichTextFieldModifications(UnitTestCase):

    def setUp(self):
        super(TestRichTextFieldModifications, self).setUp()
        self.field = RichTextField(
            instance = Article(),
            model = Article,
            syntax_processor_name = "markdown",
            field_name = "text",
            required = True,
            label = "Text"
        )


    def test_retrieve_empty_source_for_empty_article(self):
        self.assert_equals(u'', self.field.get_source().content)

    def test_source_available_for_empty_article(self):
        self.assert_equals(u'', self.field.get_source_text())

    def test_render_available_for_empty_article(self):
        self.assert_equals(u'<p></p>', self.field.get_rendered_text().strip())

    def test_value_error_raised_when_accessing_source_without_instance(self):
        field = RichTextField(
            instance = None,
            model = Article,
            syntax_processor_name = "markdown",
            field_name = "text",
            required = True,
            label = "Text"
        )

        self.assert_raises(ValueError, field.get_source)

class TestCzechtileFieldCleaning(DatabaseTestCase):
    def setUp(self):
        try:
            import czechtile
        except ImportError:
            raise SkipTest("Czechtile not installed, skipping")
        super(TestCzechtileFieldCleaning, self).setUp()

        self.text = u"""= Test =
of ""Czechtile"" text.
"""
        self.text_czechtile = u"<h1>Test</h1><p>of <em>Czechtile</em> text.</p>"<commit_msg>Forgotten word<commit_after># -*- coding: utf-8 -*-
from django.forms import ValidationError

from djangosanetesting.cases import UnitTestCase, DatabaseTestCase

from djangomarkup.fields import RichTextField, post_save_listener
from djangomarkup.models import SourceText

from exampleapp.models import Article

class TestRichTextFieldModifications(UnitTestCase):

    def setUp(self):
        super(TestRichTextFieldModifications, self).setUp()
        self.field = RichTextField(
            instance = Article(),
            model = Article,
            syntax_processor_name = "markdown",
            field_name = "text",
            required = True,
            label = "Text"
        )


    def test_retrieve_empty_source_for_empty_article(self):
        self.assert_equals(u'', self.field.get_source().content)

    def test_source_available_for_empty_article(self):
        self.assert_equals(u'', self.field.get_source_text())

    def test_render_available_for_empty_article(self):
        self.assert_equals(u'<p></p>', self.field.get_rendered_text().strip())

    def test_value_error_raised_when_accessing_source_without_instance(self):
        field = RichTextField(
            instance = None,
            model = Article,
            syntax_processor_name = "markdown",
            field_name = "text",
            required = True,
            label = "Text"
        )

        self.assert_raises(ValueError, field.get_source)

class TestCzechtileFieldCleaning(DatabaseTestCase):
    def setUp(self):
        try:
            import czechtile
        except ImportError:
            raise self.SkipTest("Czechtile not installed, skipping")
        super(TestCzechtileFieldCleaning, self).setUp()

        self.text = u"""= Test =
of ""Czechtile"" text.
"""
        self.text_czechtile = u"<h1>Test</h1><p>of <em>Czechtile</em> text.</p>"
{'fraction_non_alphanumeric': 0.09967585089141005, 'fraction_numerical': 0.0016207455429497568, 'mean_word_length': 2.9020021074815596, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4605991', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1068, 'n_words': 202}