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