def test_get_diff(self):
     diff = Diff(self.resource, self.book, False)
     book2 = Book(name="Some other book")
     diff.compare_with(self.resource, book2)
     html = diff.as_html()
     headers = self.resource.get_export_headers()
     self.assertEqual(html[headers.index('name')],
                      '<span>Some </span><ins style="background:#e6ffe6;">'
                      'other </ins><span>book</span>')
     self.assertFalse(html[headers.index('author_email')])
 def test_get_diff(self):
     diff = Diff(self.resource, self.book, False)
     book2 = Book(name="Some other book")
     diff.compare_with(self.resource, book2)
     html = diff.as_html()
     headers = self.resource.get_export_headers()
     self.assertEqual(html[headers.index('name')],
                      u'<span>Some </span><ins style="background:#e6ffe6;">'
                      u'other </ins><span>book</span>')
     self.assertFalse(html[headers.index('author_email')])
 def test_get_diff_by_word(self):
     self.book.price = Decimal('10.25')
     diff = Diff(self.resource, self.book, False)
     book2 = Book(price=Decimal('20.25'))
     diff.compare_with(self.resource, book2)
     html = diff.as_html()
     headers = self.resource.get_export_headers()
     self.assertEqual(
         html[headers.index('price')],
         '<del style="background:#ffe6e6;">10.25</del>'
         '<ins style="background:#e6ffe6;">20.25</ins>')
Exemplo n.º 4
0
 def test_get_diff_with_callable_related_manager(self):
     resource = AuthorResource()
     author = Author(name="Some author")
     author.save()
     author2 = Author(name="Some author")
     self.book.author = author
     self.book.save()
     diff = Diff(self.resource, author, False)
     diff.compare_with(self.resource, author2)
     html = diff.as_html()
     headers = resource.get_export_headers()
     self.assertEqual(html[headers.index('books')],
                      '<span>core.Book.None</span>')
 def test_get_diff_with_callable_related_manager(self):
     resource = AuthorResource()
     author = Author(name="Some author")
     author.save()
     author2 = Author(name="Some author")
     self.book.author = author
     self.book.save()
     diff = Diff(self.resource, author, False)
     diff.compare_with(self.resource, author2)
     html = diff.as_html()
     headers = resource.get_export_headers()
     self.assertEqual(html[headers.index('books')],
                      '<span>core.Book.None</span>')