Exemplo n.º 1
0
    def test_simple_import(self, parent_cover_changed):
        child = Book.from_text_and_meta(ContentFile(self.TEXT), self.child)
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent)
        parent_cover_changed.assert_called_with(child)

        # Now reimport parent.
        parent_cover_changed.reset_mock()
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent, overwrite=True)
        self.assertEqual(parent_cover_changed.call_count, 0)

        # Now change cover in parent.
        parent_cover_changed.reset_mock()
        self.parent.cover_url = "http://example.com/other-cover.jpg"
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent, overwrite=True)
        parent_cover_changed.assert_called_with(child)
Exemplo n.º 2
0
    def test_new_child(self, parent_cover_changed):
        # Add parent without child first.
        parts, self.parent.parts = self.parent.parts, []
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent)

        # Now import child and reimport parent.
        child = Book.from_text_and_meta(ContentFile(self.TEXT), self.child)
        self.parent.parts = parts
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent, overwrite=True)
        parent_cover_changed.assert_called_with(child)

        # Now remove the child.
        parent_cover_changed.reset_mock()
        self.parent.parts = []
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent, overwrite=True)
        parent_cover_changed.assert_called_with(child)
Exemplo n.º 3
0
    def test_book_with_footnote(self):
        book_text = """<utwor>
        <opowiadanie>
            <akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
            <akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
            <akap><pe><slowo_obce>rose</slowo_obce> (techn.) --- #FF007F.</pe></akap>
        </opowiadanie></utwor>
        """

        book = Book.from_text_and_meta(ContentFile(book_text), self.book_info)

        self.assertEqual(
            len(self.client.get('/przypisy/').context['object_list']), 2,
            'There should be two notes on the note list.')

        self.assertEqual(
            len(self.client.get('/przypisy/?ltr=a').context['object_list']), 0,
            'There should not be a note for the letter A.')

        self.assertEqual(
            len(self.client.get('/przypisy/?ltr=r').context['object_list']), 2,
            'Both notes start with the letter R.')

        self.assertEqual(
            len(
                self.client.get(
                    '/przypisy/?qual=techn.').context['object_list']), 1,
            'There should be a note qualified with \'techn.\' qualifier.')
Exemplo n.º 4
0
    def test_book_with_footnote(self):
        book_text = """<utwor>
        <opowiadanie>
            <akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
            <akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
            <akap><pe><slowo_obce>rose</slowo_obce> (techn.) --- #FF007F.</pe></akap>
        </opowiadanie></utwor>
        """

        book = Book.from_text_and_meta(ContentFile(book_text), self.book_info)

        self.assertEqual(
            len(self.client.get('/przypisy/').context['object_list']),
            2,
            'There should be two notes on the note list.')

        self.assertEqual(
            len(self.client.get('/przypisy/?ltr=a').context['object_list']),
            0,
            'There should not be a note for the letter A.')

        self.assertEqual(
            len(self.client.get('/przypisy/?ltr=r').context['object_list']),
            2,
            'Both notes start with the letter R.')

        self.assertEqual(
            len(self.client.get('/przypisy/?qual=techn.').context['object_list']),
            1,
            'There should be a note qualified with \'techn.\' qualifier.')
Exemplo n.º 5
0
    def test_simple_import(self, parent_cover_changed):
        child = Book.from_text_and_meta(ContentFile(self.TEXT), self.child)
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent)
        parent_cover_changed.assert_called_with(child)

        # Now reimport parent.
        parent_cover_changed.reset_mock()
        parent = Book.from_text_and_meta(ContentFile(self.TEXT),
                                         self.parent,
                                         overwrite=True)
        self.assertEqual(parent_cover_changed.call_count, 0)

        # Now change cover in parent.
        parent_cover_changed.reset_mock()
        self.parent.cover_url = "http://example.com/other-cover.jpg"
        parent = Book.from_text_and_meta(ContentFile(self.TEXT),
                                         self.parent,
                                         overwrite=True)
        parent_cover_changed.assert_called_with(child)
Exemplo n.º 6
0
    def test_new_child(self, parent_cover_changed):
        # Add parent without child first.
        parts, self.parent.parts = self.parent.parts, []
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent)

        # Now import child and reimport parent.
        child = Book.from_text_and_meta(ContentFile(self.TEXT), self.child)
        self.parent.parts = parts
        parent = Book.from_text_and_meta(ContentFile(self.TEXT),
                                         self.parent,
                                         overwrite=True)
        parent_cover_changed.assert_called_with(child)

        # Now remove the child.
        parent_cover_changed.reset_mock()
        self.parent.parts = []
        parent = Book.from_text_and_meta(ContentFile(self.TEXT),
                                         self.parent,
                                         overwrite=True)
        parent_cover_changed.assert_called_with(child)
Exemplo n.º 7
0
    def test_book_with_footnote(self):
        BOOK_TEXT = """<utwor>
        <opowiadanie>
            <akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
        </opowiadanie></utwor>
        """

        book = Book.from_text_and_meta(ContentFile(BOOK_TEXT), self.book_info)

        self.assertEqual(
            len(self.client.get('/przypisy/').context['object_list']), 1,
            'There should be a note on the note list.')

        self.assertEqual(
            len(self.client.get('/przypisy/a/').context['object_list']), 0,
            'There should not be a note for the letter A.')

        self.assertEqual(
            len(self.client.get('/przypisy/r/').context['object_list']), 1,
            'There should be a note for the letter R.')
Exemplo n.º 8
0
    def test_book_with_footnote(self):
        BOOK_TEXT = """<utwor>
        <opowiadanie>
            <akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
        </opowiadanie></utwor>
        """

        book = Book.from_text_and_meta(ContentFile(BOOK_TEXT), self.book_info)

        self.assertEqual(
            len(self.client.get('/przypisy/').context['object_list']),
            1,
            'There should be a note on the note list.')

        self.assertEqual(
            len(self.client.get('/przypisy/a/').context['object_list']),
            0,
            'There should not be a note for the letter A.')

        self.assertEqual(
            len(self.client.get('/przypisy/r/').context['object_list']),
            1,
            'There should be a note for the letter R.')
Exemplo n.º 9
0
 def test_change_cover(self, parent_cover_changed):
     child = Book.from_text_and_meta(ContentFile(self.TEXT), self.child)
     parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent)
     parent_cover_changed.assert_called_with(child)
Exemplo n.º 10
0
 def test_change_cover(self, parent_cover_changed):
     child = Book.from_text_and_meta(ContentFile(self.TEXT), self.child)
     parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent)
     parent_cover_changed.assert_called_with(child)