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.document import WLDocument
12 from librarian.parser import WLDocument as LegacyWLDocument
13 from nose.tools import *
14 from .utils import get_fixture
17 class TransformTest(TestCase):
20 def test_transform_legacy(self):
21 expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.legacy.html')
23 html = LegacyWLDocument.from_file(
24 get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
25 ).as_html().get_bytes().decode('utf-8')
27 self.assertEqual(html, io.open(expected_output_file_path).read())
29 def test_transform(self):
30 expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.html')
32 filename=get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
33 ).build('html').get_bytes().decode('utf-8')
35 self.assertEqual(html, io.open(expected_output_file_path).read())
39 def test_no_dublincore():
40 LegacyWLDocument.from_file(
41 get_fixture('text', 'asnyk_miedzy_nami_nodc.xml')
45 def test_passing_parse_dublincore_to_transform():
46 """Passing parse_dublincore=False to transform omits DublinCore parsing."""
47 LegacyWLDocument.from_file(
48 get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
49 parse_dublincore=False,
54 assert not LegacyWLDocument.from_bytes(
56 parse_dublincore=False,