1 # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 """XmlUpdater tests."""
6 from documents.test_utils import get_fixture
7 from django.test import TestCase
8 from django.contrib.auth.models import User
9 from documents.models import Book
10 from documents.management import XmlUpdater
11 from librarian import DCNS
14 class XmlUpdaterTests(TestCase):
15 class SimpleUpdater(XmlUpdater):
16 @XmlUpdater.fixes_elements('.//' + DCNS('title'))
17 def fix_title(element, **kwargs):
18 element.text = element.text + " fixed"
22 self.user = User.objects.create(username='tester')
23 text = get_fixture('chunk1.xml')
24 Book.create(self.user, text, slug='test-book')
25 self.title = "Do M***"
27 def test_xml_updater(self):
28 self.SimpleUpdater().run(self.user)
30 Book.objects.get(slug='test-book').wldocument(
31 publishable=False).book_info.title,