2 from librarian import xmlutils
4 from librarian.pyhtml import EduModule
5 from nose.tools import *
6 from tests.utils import get_fixture
9 xml = etree.fromstring("<a><b>BBBB</b><c>CCCC</c></a>")
11 assert_equals(hg.next(xml), xml[0])
12 assert_equals(hg.next(xml[0]), xml[1])
13 assert_equals(hg.next(xml[1]), None)
17 class Foo(xmlutils.Xmill):
19 super(Foo, self).__init__()
22 def handle_title(self, ele):
23 return "Title: ``%s''" % ele.text
25 def handle_artist(self, ele):
26 return "Artist: %s" % ele.text
28 def handle_song(self, ele):
29 if ele.getnext() is not None:
30 return "\n","--------------------\n"
34 def test_xml_generation():
38 <title>Oursoul</title>
39 <artist>Hindi Zahra</artist>
42 <title>Visitor</title>
43 <artist>Portico Quartet</artist>
48 txt = Foo().generate(etree.fromstring(xml))
53 xml = open(get_fixture('edumed', 'gim-wizerunek-w-sieci.xml')).read()
55 out = em.generate(etree.fromstring(xml))
56 print out.encode('utf-8')