Ejemplo n.º 1
0
 def test_book_inf_authors(self):
     "Tests getting book authors"
     Author(name='Name').save()
     xml_string = '''
     <book>
         <title>Book title   </title>
         <authors>
             <author>
                 <name>Name2</name>
                 <alias>Alias</alias>
             </author>
             <author>
                 <name>Name</name>
                 <alias>Alias</alias>
             </author>
             <author>
                 <name>  
                 </name>
             </author>
         </authors>
         <files>
           <file>
             <link>link</link>
           </file>
         </files>
     </book>
     ''';
     xml = etree.fromstring(xml_string)
     (book, authors, book_files, annotations) = get_book_inf(xml)
     self.failUnlessEqual(authors[0], Author.objects.all()[1])
     self.failUnlessEqual(authors[1], Author.objects.all()[0])
     self.failUnlessEqual(Author.objects.all().count(), 2)
Ejemplo n.º 2
0
 def test_book_inf(self):
     "Tests getting book inf"
     xml_string = '''
     <book>
         <title>Book title   </title>
         <lang>en</lang>
         <files>
           <file>
             <link>link</link>
           </file>
         </files>
     </book>
     ''';
     xml = etree.fromstring(xml_string)
     (book, authors, book_files, annotations) = get_book_inf(xml)
     self.failUnlessEqual(book.title, 'Book title')
     self.failUnlessEqual(book.language, self.unknown_language)
Ejemplo n.º 3
0
 def test_book_inf_files(self):
     "Tests getting book_files"
     link_hash = md5('link').hexdigest()
     BookFile(link='link', link_hash=link_hash).save()
     xml_string = '''
     <book>
         <title>Book title   </title>
         <files>
         <file>
             <link>link  </link>
             <size>wrong</size>
         </file>
         <file>
         <link>link2</link>
         <size>645</size>
         </file>
     </files>
     </book>
     ''';
     xml = etree.fromstring(xml_string)
     (book, authors, book_files, annotations) = get_book_inf(xml)
     self.failUnlessEqual(book_files[0], BookFile.objects.all()[0])
     self.failUnlessEqual(book_files[1], BookFile.objects.all()[1])
     self.failUnlessEqual(BookFile.objects.all().count(), 2)