Exemple #1
0
 def test_title(self):  # {{{
     def rt(root):
         return read_title(root, read_prefixes(root), read_refines(root))
     def st(root, title, title_sort=None):
         set_title(root, read_prefixes(root), read_refines(root), title, title_sort)
         return rt(root)
     root = self.get_opf('''<dc:title/><dc:title id='t'>xxx</dc:title>''')
     self.ae(rt(root), 'xxx')
     self.ae(st(root, 'abc', 'cba'), 'abc')
     self.ae(read_title_sort(root, read_prefixes(root), read_refines(root)), 'cba')
     root = self.get_opf('''<dc:title>yyy</dc:title><dc:title id='t'>x  xx
         </dc:title><meta refines='#t' property='title-type'>main</meta><meta name="calibre:title_sort" content="sorted"/>''')
     self.ae(rt(root), 'x xx')
     self.ae(read_title_sort(root, read_prefixes(root), read_refines(root)), 'sorted')
     self.ae(st(root, 'abc'), 'abc')
    def test_title(self):  # {{{
        def rt(root):
            return read_title(root, read_prefixes(root), read_refines(root))

        def st(root, title, title_sort=None):
            set_title(root, read_prefixes(root), read_refines(root), title, title_sort)
            return rt(root)
        root = self.get_opf('''<dc:title/><dc:title id='t'>xxx</dc:title>''')
        self.ae(rt(root), 'xxx')
        self.ae(st(root, 'abc', 'cba'), 'abc')
        self.ae(read_title_sort(root, read_prefixes(root), read_refines(root)), 'cba')
        root = self.get_opf('''<dc:title>yyy</dc:title><dc:title id='t'>x  xx
            </dc:title><meta refines='#t' property='title-type'>main</meta><meta name="calibre:title_sort" content="sorted"/>''')
        self.ae(rt(root), 'x xx')
        self.ae(read_title_sort(root, read_prefixes(root), read_refines(root)), 'sorted')
        self.ae(st(root, 'abc'), 'abc')