def test_create_annotation(self): # Create annotation = odf_create_annotation(u"Lost Dialogs", creator=u"Plato", date=datetime(2009, 6, 22, 17, 18, 42)) expected = ('<office:annotation>' '<text:p>' 'Lost Dialogs' '</text:p>' '<dc:creator>Plato</dc:creator>' '<dc:date>2009-06-22T17:18:42</dc:date>' '</office:annotation>') self.assertEqual(annotation.serialize(), expected)
def test_insert_annotation(self): text = u"It's like you're in a cave." creator = u"Plato" date = datetime(2009, 8, 19) annotation = odf_create_annotation(text, creator=creator, date=date) paragraph = odf_create_paragraph(u"Un paragraphe") paragraph.insert_annotation(annotation, after=u"para") expected = ('<text:p>Un para' '<office:annotation>' '<text:p>It\'s like you\'re in a cave.</text:p>' '<dc:creator>Plato</dc:creator>' '<dc:date>2009-08-19T00:00:00</dc:date>' '</office:annotation>' 'graphe</text:p>') self.assertEqual(paragraph.serialize(), expected)
body.append(odf_create_heading(1, u"Footnotes")) paragraph = odf_create_paragraph(u'A paragraph with a footnote ' u'about references in it.') note = odf_create_note(note_id='note1', citation=u"1", body=u'Author, A. (2007). "How to cite references", ' u'New York: McGraw-Hill.') paragraph.insert_note(note, after=u"graph") body.append(paragraph) # # Annotations # body.append(odf_create_heading(1, u"Annotations")) paragraph = odf_create_paragraph(u"A paragraph with an annotation " u"in the middle.") annotation = odf_create_annotation(u"It's so easy!", creator=u"Luis") paragraph.insert_annotation(annotation, after=u"annotation") body.append(paragraph) # # Tables # body.append(odf_create_heading(1, u"Tables")) body.append(odf_create_paragraph(u"A table:")) table = odf_create_table(u"Table 1", width=3, height=3) body.append(table) # # Applying styles # body.append(odf_create_heading(1, u"Applying Styles"))
paragraph = odf_create_paragraph(u'A paragraph with a footnote ' u'about references in it.') note = odf_create_note(note_id='note1', citation=u"1", body=u'Author, A. (2007). "How to cite references", ' u'New York: McGraw-Hill.') paragraph.insert_note(note, after=u"graph") body.append(paragraph) # # Annotations # body.append(odf_create_heading(1, u"Annotations")) paragraph = odf_create_paragraph(u"A paragraph with an annotation " u"in the middle.") annotation = odf_create_annotation(u"It's so easy!", creator=u"Luis") paragraph.insert_annotation(annotation, after=u"annotation") body.append(paragraph) # # Tables # body.append(odf_create_heading(1, u"Tables")) body.append(odf_create_paragraph(u"A table:")) table = odf_create_table(u"Table 1", width=3, height=3) body.append(table) # # Applying styles # body.append(odf_create_heading(1, u"Applying Styles"))