1 # -*- coding: utf-8 -*-
3 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6 from __future__ import unicode_literals
9 from unittest import TestCase
10 from librarian import NoDublinCore
11 from librarian.builders import builders
12 from librarian.document import WLDocument
13 from librarian.parser import WLDocument as LegacyWLDocument
14 from nose.tools import *
15 from .utils import get_fixture
18 class TransformTest(TestCase):
21 def test_transform_legacy(self):
22 expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.legacy.html')
24 html = LegacyWLDocument.from_file(
25 get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
26 ).as_html().get_bytes().decode('utf-8')
28 self.assertEqual(html, io.open(expected_output_file_path).read())
30 def test_transform(self):
31 expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.html')
33 filename=get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
34 ).build(builders['html']).get_bytes().decode('utf-8')
36 self.assertEqual(html, io.open(expected_output_file_path).read())
40 def test_no_dublincore():
41 LegacyWLDocument.from_file(
42 get_fixture('text', 'asnyk_miedzy_nami_nodc.xml')
46 def test_passing_parse_dublincore_to_transform():
47 """Passing parse_dublincore=False to transform omits DublinCore parsing."""
48 LegacyWLDocument.from_file(
49 get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
50 parse_dublincore=False,
55 assert not LegacyWLDocument.from_bytes(
57 parse_dublincore=False,