Ejemplo n.º 1
0
 def test_output_rendered_in_html(self):
     stream = StringIO()
     stream.write(u'A,B,C'.encode('utf-8'))
     stream.write(u'ő,ú,á'.encode('utf-8'))
     stream.write(u'é,ű,í'.encode('utf-8'))
     stream.seek(0)
     db = module.Database(stream)
     dct = {
         'database':
         db,
         'document_template':
         Template('{% for entry in entries %}{{entry}}{% endfor %}'),
         'entry_template':
         Template('{{A}}, {{B}}, {{C}}'),
         'output':
         StringIO(),
         'encoding':
         'html'
     }
     conf = module.Configuration(dct)
     document = conf.render_document()
     try:
         document.decode('ascii')
     except Exception:
         self.fail('Could not decode string as ascii.')
Ejemplo n.º 2
0
 def test_render_document(self):
     db = module.Database(StringIO())
     dct = {
         'database': db,
         'document_template': Template('A document.'),
         'entry_template': Template(''),
         'output': StringIO()
     }
     conf = module.Configuration(dct)
     self.assertEqual(conf.render_document(), 'A document.')
Ejemplo n.º 3
0
 def test_entry_template_is_compiled(self):
     db = module.Database(StringIO())
     dct = {
         'database': db,
         'document_template': Template(''),
         'entry_template': Template(''),
         'output': StringIO()
     }
     conf = module.Configuration(dct)
     self.assertIsInstance(conf.entry_template, Template)
Ejemplo n.º 4
0
 def test_configuration_accepts_dictionary(self):
     db = module.Database(StringIO())
     dct = {
         'database': db,
         'document_template': Template(''),
         'entry_template': Template(''),
         'output': StringIO()
     }
     conf = module.Configuration(dct)
     self.assertIsInstance(conf, module.Configuration)
Ejemplo n.º 5
0
 def test_write_document(self):
     db = module.Database(StringIO())
     output = StringIO()
     dct = {
         'database': db,
         'document_template': Template('A document.'),
         'entry_template': Template(''),
         'output': output
     }
     conf = module.Configuration(dct)
     conf.write_document()
     output.seek(0)
     self.assertEqual(output.read(), 'A document.')
Ejemplo n.º 6
0
    def test_read_entries(self):
        stream = StringIO()
        stream.write('''A,B,C
			1,2,3
			4,5,6''')
        stream.seek(0)
        db = module.Database(stream)
        dct = {
            'database': db,
            'document_template': Template('A document.'),
            'entry_template': Template(''),
            'output': StringIO()
        }
        conf = module.Configuration(dct)
        [
            self.assertIsInstance(entry, module.Entry)
            for entry in conf.read_entries()
        ]
Ejemplo n.º 7
0
    def test_entry_has_filters(self):
        stream = StringIO()
        stream.write('''A,B,C
			1,2,3
			4,5,6''')
        stream.seek(0)
        db = module.Database(stream)
        dct = {
            'database': db,
            'document_template': Template('A document.'),
            'entry_template': Template(''),
            'output': StringIO(),
            'filters': {
                'A': ['split', 'join']
            }
        }
        conf = module.Configuration(dct)
        self.assertDictEqual(conf.read_entries()[0].filters,
                             {'A': ['split', 'join']})