def test_unicode_to_unicode(self): entry = module.Entry(dict(text=u'szőlőfeldolgozó üzem'), Template('{{text}}')) self.assertEqual(entry.render(), u'szőlőfeldolgozó üzem')
def test_document_renders_entries(self): entry = module.Entry({}, Template('An entry.')) document = module.Document( [entry] * 3, Template('{% for entry in entries %}{{entry}}{% endfor %}')) self.assertEqual(str(document), 'An entry.An entry.An entry.')
def callable(): entry = module.Entry(dict(a='1, 2, 3', render=4), Template(''))
def callable(): entry = module.Entry(dict(a='1, 2, 3', apply_all_filters=4), Template(''))
def test_field_can_be_reached_directly(self): entry = module.Entry(dict(a='1, 2, 3', b=4), Template('')) self.assertEqual(entry.b, '4')
def callable(): entry = module.Entry(dict(a='1, 2, 3', b=4), Template('')) print entry.c
def test_filters_applied_before_rendering(self): entry = module.Entry(dict(a='123', b=4), Template('{{a}}'), dict(a=['append:4'])) self.assertEqual(entry.render(), '1234')
def test_filters_not_applied_twice(self): entry = module.Entry(dict(a='123', b=4), Template(''), dict(a=['append:4'])) entry.apply_all_filters() entry.apply_all_filters() self.assertEqual(entry.fields['a'], '1234')
def callable(): entry = module.Entry(dict(a=1), Template(''), dict(b=['split']))
def test_filters_are_optional(self): entry = module.Entry(dict(a='1, 2, 3', b=4), Template('')) entry.apply_all_filters() self.assertEqual(entry.fields['a'], '1, 2, 3')
def test_filter_does_not_change_other_field(self): entry = module.Entry(dict(a='1, 2, 3', b=4), Template(''), dict(a=['split'])) entry.apply_all_filters() self.assertEqual(entry.fields['b'], 4)
def test_filter_knownvalues(self): entry = module.Entry(dict(a='1, 2, 3', b=4), Template(''), dict(a=['split'])) entry.apply_all_filters() self.assertListEqual(entry.fields['a'], ['1', '2', '3'])
def test_known_examples(self): entry = module.Entry(dict(x=1), Template('Value is {{x}}')) self.assertEqual(str(entry), 'Value is 1')
def test_entry_as_string(self): entry = module.Entry({}, Template('Dummy template')) self.assertEqual(str(entry), 'Dummy template')
def test_entry_accepts_none(self): entry = module.Entry({})