# Path: easymode/tests/models.py
# class TestL10nModel(models.Model):
#     """
#     Used in easymode.tests.testcases.testi18n.Testi18n and
#     easymode.tests.testcases.testsafefields.TestSafeFields.
#     """
#     title = models.CharField(max_length=200)
#     description = SafeTextField()
#     body = SafeHTMLField(default='hi i am an error')
#     price = models.FloatField()
# 
#     def __unicode__(self):
#         return u"%s%s" % (self.__class__.__name__, self.pk)


from django.core.urlresolvers import reverse
from django.test import TestCase
from easymode.tests.models import TestL10nModel
from easymode.tests.testcases import initdb



__all__ = ('TestSafeFields',)

@initdb
class TestSafeFields(TestCase):
    "Test for fields that strip cariage returns."
    
    fixtures = ['auth-user', 'tests-testl10nmodel']
    
    def test_safe_fields_strip_cariage_returns(self):
        "Safe fields should strip cariage returns from the input"
                
        h = {
            'title': "Ik ben de groot moeftie van oeral",
            'description': "Ik weet\r weinig tot niks van brei \rcursussen",
            'body':"Het zou kunnen dat\r linksaf\r slaan hier een goede keuze is.",
            'price':34.0,
        }
        
        if self.client.login(username='admin', password='admin'):
            
            add_view_url = reverse("admin:tests_testl10nmodel_add")            
            response = self.client.post(add_view_url, h)


# Path: easymode/tests/models.py
# class TestL10nModel(models.Model):
#     """
#     Used in easymode.tests.testcases.testi18n.Testi18n and
#     easymode.tests.testcases.testsafefields.TestSafeFields.
#     """
#     title = models.CharField(max_length=200)
#     description = SafeTextField()
#     body = SafeHTMLField(default='hi i am an error')
#     price = models.FloatField()
# 
#     def __unicode__(self):
#         return u"%s%s" % (self.__class__.__name__, self.pk)


# Path: easymode/tests/testcases/testsafefields.py
from django.core.urlresolvers import reverse
from django.test import TestCase
from easymode.tests.models import TestL10nModel
from easymode.tests.testcases import initdb




__all__ = ('TestSafeFields',)

@initdb
class TestSafeFields(TestCase):
    "Test for fields that strip cariage returns."
    
    fixtures = ['auth-user', 'tests-testl10nmodel']
    
    def test_safe_fields_strip_cariage_returns(self):
        "Safe fields should strip cariage returns from the input"
                
        h = {
            'title': "Ik ben de groot moeftie van oeral",
            'description': "Ik weet\r weinig tot niks van brei \rcursussen",
            'body':"Het zou kunnen dat\r linksaf\r slaan hier een goede keuze is.",
            'price':34.0,
        }
        
        if self.client.login(username='admin', password='admin'):
            
            add_view_url = reverse("admin:tests_testl10nmodel_add")            
            response = self.client.post(add_view_url, h)


            i = TestL10nModel.objects.get(pk=3)