Exemplo n.º 1
0
 def test_get_variable_decl(self):
     clone = self.document.clone()
     body = clone.get_body()
     variable_decl = body.get_variable_decl(u"Variabilité")
     expected = ('<text:variable-decl office:value-type="float" '
                   'text:name="%s"/>' % convert_unicode(u"Variabilité"))
     self.assertEqual(variable_decl.serialize(), expected)
Exemplo n.º 2
0
 def test_with_user_field(self):
     user_field_decl = odf_create_user_field_decl(u'你好 Zoé', 42)
     set_value(user_field_decl, u'你好 Zoé')
     expected = (('<text:user-field-decl office:value-type="string" '
                    'office:string-value="%s" text:name="%s"/>') %
                         ((convert_unicode(u'你好 Zoé'),) * 2))
     self.assertEqual(user_field_decl.serialize(), expected)
Exemplo n.º 3
0
 def test_create_variable_get(self):
     variable_get = odf_create_variable_get(u'你好 Zoé', value=42)
     expected = ('<text:variable-get text:name="%s" '
                   'office:value-type="float" office:value="42">'
                   '42'
                 '</text:variable-get>') % convert_unicode(u'你好 Zoé')
     self.assertEqual(variable_get.serialize(), expected)
Exemplo n.º 4
0
 def test_get_bookmark_start_list(self):
     bookmark_start = odf_create_bookmark_start(u'你好 Zoé')
     self.body.append(bookmark_start)
     get = self.body.get_bookmark_starts()[0]
     expected = ('<text:bookmark-start text:name="%s"/>' %
                 convert_unicode(u'你好 Zoé'))
     self.assertEqual(get.serialize(), expected)
Exemplo n.º 5
0
 def test_create_user_field_input(self):
     user_field_input = odf_create_user_field_input(u'你好 Zoé', value=42)
     expected = ('<text:user-field-input text:name="%s" '
                   'office:value-type="float" office:value="42">'
                   '42'
                 '</text:user-field-input>') % convert_unicode(u'你好 Zoé')
     self.assertEqual(user_field_input.serialize(), expected)
Exemplo n.º 6
0
 def test_create_list(self):
     item = odf_create_list_item()
     a_list = odf_create_list([u"你好 Zoé"])
     expected = (
         "<text:list>" "<text:list-item>" "<text:p>%s</text:p>" "</text:list-item>" "</text:list>"
     ) % convert_unicode(u"你好 Zoé")
     self.assertEqual(a_list.serialize(), expected)
Exemplo n.º 7
0
 def test_get_bookmark_end_list(self):
     body = self.body
     bookmark_end = odf_create_bookmark_end(u"你好 Zoé")
     body.append_element(bookmark_end)
     get = body.get_bookmark_end_list()[0]
     expected = '<text:bookmark-end text:name="%s"/>' % convert_unicode(u"你好 Zoé")
     self.assertEqual(get.serialize(), expected)
Exemplo n.º 8
0
 def test_get_bookmark_start(self):
     body = self.body
     bookmark_start = odf_create_bookmark_start(u"你好 Zoé")
     body.append_element(bookmark_start)
     get = body.get_bookmark_start_by_name(u"你好 Zoé")
     expected = '<text:bookmark-start text:name="%s"/>' % convert_unicode(u"你好 Zoé")
     self.assertEqual(get.serialize(), expected)
 def test_get_reference_mark_list(self):
     body = self.body
     reference_mark = odf_create_reference_mark(u'你好 Zoé')
     body.append_element(reference_mark)
     get = body.get_reference_mark_list()[0]
     expected = ('<text:reference-mark text:name="%s"/>' %
                 convert_unicode(u'你好 Zoé'))
     self.assertEqual(get.serialize(), expected)
Exemplo n.º 10
0
 def test_get_reference_mark_end(self):
     body = self.body
     reference_mark_end = odf_create_reference_mark_end(u'你好 Zoé')
     body.append(reference_mark_end)
     get = body.get_reference_mark_end(name=u'你好 Zoé')
     expected = ('<text:reference-mark-end text:name="%s"/>' %
                 convert_unicode(u'你好 Zoé'))
     self.assertEqual(get.serialize(), expected)
Exemplo n.º 11
0
 def test_get_bookmark(self):
     body = self.body
     bookmark = odf_create_bookmark(u'你好 Zoé')
     body.append(bookmark)
     get = body.get_bookmark(name=u'你好 Zoé')
     expected = ('<text:bookmark text:name="%s"/>' %
                 convert_unicode(u'你好 Zoé'))
     self.assertEqual(get.serialize(), expected)
Exemplo n.º 12
0
 def test_get_reference_mark_start(self):
     body = self.body
     reference_mark_start = odf_create_reference_mark_start(u'你好 Zoé')
     body.append_element(reference_mark_start)
     get = body.get_reference_mark_start_by_name(u'你好 Zoé')
     expected = ('<text:reference-mark-start text:name="%s"/>' %
                 convert_unicode(u'你好 Zoé'))
     self.assertEqual(get.serialize(), expected)
Exemplo n.º 13
0
 def test_get_user_field_decl(self):
     clone = self.document.clone()
     body = clone.get_body()
     user_field_decl = body.get_user_field_decl(u"Champêtre")
     expected = ('<text:user-field-decl office:value-type="float" '
                   'office:value="1" text:name="%s"/>' %
                   convert_unicode(u"Champêtre"))
     self.assertEqual(user_field_decl.serialize(), expected)
Exemplo n.º 14
0
 def test_create_list(self):
     item = odf_create_list_item()
     a_list = odf_create_list([u'你好 Zoé'])
     expected = (('<text:list>'
                    '<text:list-item>'
                      '<text:p>%s</text:p>'
                    '</text:list-item>'
                  '</text:list>') % convert_unicode(u'你好 Zoé'))
     self.assertEqual(a_list.serialize(), expected)
Exemplo n.º 15
0
 def test_get_reference_mark_start(self):
     body = self.body
     para = body.get_paragraph()
     reference_mark_start = odf_create_reference_mark_start(u'你好 Zoé')
     para.append(reference_mark_start)
     get = body.get_reference_mark_start(name=u'你好 Zoé')
     expected = ('<text:reference-mark-start text:name="%s"/>' %
                 convert_unicode(u'你好 Zoé'))
     self.assertEqual(get.serialize(), expected)
Exemplo n.º 16
0
 def test_create_user_defined_3_existing(self):
     element = odf_create_user_defined(u'Référence',
                             from_document=self.document)
     expected = (
                 '<text:user-defined text:name="%s" '
                 'office:value-type="boolean" '
                 'office:boolean-value="true">'
                 'true</text:user-defined>') % convert_unicode(u'Référence')
     self.assertEqual(element.serialize(), expected)
Exemplo n.º 17
0
 def test_get_reference_mark_single_list(self):
     body = self.body
     para = body.get_paragraph()
     reference_mark = odf_create_reference_mark(u'你好 Zoé')
     para.append(reference_mark)
     get = body.get_reference_marks_single()[0]
     expected = ('<text:reference-mark text:name="%s"/>' %
                 convert_unicode(u'你好 Zoé'))
     self.assertEqual(get.serialize(), expected)
Exemplo n.º 18
0
 def test_get_bookmark_end_list(self):
     body = self.body
     bookmark_end = odf_create_bookmark_end(u'你好 Zoé')
     para = self.body.get_paragraph()
     para.append(bookmark_end)
     get = body.get_bookmark_ends()[0]
     expected = ('<text:bookmark-end text:name="%s"/>' %
                 convert_unicode(u'你好 Zoé'))
     self.assertEqual(get.serialize(), expected)
Exemplo n.º 19
0
 def test_get_variable_set(self):
     clone = self.document.clone()
     body = clone.get_body()
     variable_sets = body.get_variable_sets(u"Variabilité")
     self.assertEqual(len(variable_sets), 1)
     expected = ('<text:variable-set text:name="%s" '
                   'office:value-type="float" office:value="123" '
                   'style:data-style-name="N1">123</text:variable-set>' %
                     convert_unicode(u"Variabilité"))
     self.assertEqual(variable_sets[0].serialize(), expected)
Exemplo n.º 20
0
 def test_with_variable(self):
     variable_set = odf_create_variable_set(u'你好 Zoé', 42)
     set_value(variable_set, u'你好 Zoé')
     expected = ('<text:variable-set office:value-type="string" '
                   'office:string-value="%s" text:name="%s" '
                   'text:display="none">'
                   '%s'
                 '</text:variable-set>') % (
                         (convert_unicode(u'你好 Zoé'),) * 3)
     self.assertEqual(variable_set.serialize(), expected)
Exemplo n.º 21
0
 def test_create_variable_set_datetime(self):
     date = datetime(2009, 5, 17, 23, 23, 00)
     variable_set = odf_create_variable_set(u'你好 Zoé', value=date,
                                            display=True)
     expected = ('<text:variable-set text:name="%s" '
                   'office:value-type="date" '
                   'office:date-value="2009-05-17T23:23:00">'
                   '2009-05-17T23:23:00'
                 '</text:variable-set>') % convert_unicode(u'你好 Zoé')
     self.assertEqual(variable_set.serialize(), expected)
Exemplo n.º 22
0
 def test_create_user_defined_5_nodoc(self):
     element = odf_create_user_defined(u'Référence',
                             value=False, # default value if not existing
                             value_type=u'boolean',
                             from_document=None)
     expected = (
                 '<text:user-defined text:name="%s" '
                 'office:value-type="boolean" '
                 'office:boolean-value="false">'
                 'false</text:user-defined>') % convert_unicode(u'Référence')
     self.assertEqual(element.serialize(), expected)
Exemplo n.º 23
0
 def test_with_cell(self):
     cell = odf_create_cell(42)
     set_value(cell, u'你好 Zoé')
     expected = ('<table:table-cell office:value-type="string" '
                   'office:string-value="%s">'
                   '<text:p>'
                     '%s'
                   '</text:p>'
                 '</table:table-cell>') % (
                             (convert_unicode(u'你好 Zoé'),) * 2)
     self.assertEqual(cell.serialize(), expected)
Exemplo n.º 24
0
 def test_get_user_defined(self):
     element = odf_create_user_defined(u'Référence',
                             value=False, # default value if not existing
                             value_type=u'boolean',
                             from_document=self.document)
     body = self.document.get_body()
     para = body.get_paragraph()
     para.append(element)
     user_defined = body.get_user_defined(u'Référence')
     expected = (
                 '<text:user-defined text:name="%s" '
                 'office:value-type="boolean" '
                 'office:boolean-value="true">'
                 'true</text:user-defined>') % convert_unicode(u'Référence')
     self.assertEqual(user_defined.serialize(), expected)
Exemplo n.º 25
0
 def test_create_bookmark_end(self):
     bookmark_end = odf_create_bookmark_end(u'你好 Zoé')
     expected = ('<text:bookmark-end text:name="%s"/>' %
                 convert_unicode(u'你好 Zoé'))
     self.assertEqual(bookmark_end.serialize(), expected)
Exemplo n.º 26
0
 def test_create_reference_mark(self):
     reference_mark = odf_create_reference_mark(u'你好 Zoé')
     expected = ('<text:reference-mark text:name="%s"/>' %
                 convert_unicode(u'你好 Zoé'))
     self.assertEqual(reference_mark.serialize(), expected)
Exemplo n.º 27
0
 def test_create_reference_mark_end(self):
     reference_mark_end = odf_create_reference_mark_end(u'你好 Zoé')
     expected = ('<text:reference-mark-end text:name="%s"/>' %
                 convert_unicode(u'你好 Zoé'))
     self.assertEqual(reference_mark_end.serialize(), expected)
Exemplo n.º 28
0
 def test_create_variable_set_float(self):
     variable_set = odf_create_variable_set(u'你好 Zoé', value=42)
     expected = ('<text:variable-set text:name="%s" '
                   'office:value-type="float" office:value="42" '
                   'text:display="none"/>') % convert_unicode(u'你好 Zoé')
     self.assertEqual(variable_set.serialize(), expected)
Exemplo n.º 29
0
 def test_create_variable_decl(self):
     variable_decl = odf_create_variable_decl(u'你好 Zoé', 'float')
     expected = ('<text:variable-decl office:value-type="float" '
                   'text:name="%s"/>') % convert_unicode(u'你好 Zoé')
     self.assertEqual(variable_decl.serialize(), expected)
Exemplo n.º 30
0
 def test_create_bookmark_start(self):
     bookmark_start = odf_create_bookmark_start(u"你好 Zoé")
     expected = '<text:bookmark-start text:name="%s"/>' % convert_unicode(u"你好 Zoé")
     self.assertEqual(bookmark_start.serialize(), expected)
Exemplo n.º 31
0
 def test_create_user_field_decl(self):
     user_field_decl = odf_create_user_field_decl(u'你好 Zoé', 42)
     expected = (('<text:user-field-decl text:name="%s" '
                    'office:value-type="float" office:value="42"/>') %
                   convert_unicode(u'你好 Zoé'))
     self.assertEqual(user_field_decl.serialize(), expected)
Exemplo n.º 32
0
 def test_create_bookmark_end(self):
     bookmark_end = odf_create_bookmark_end(u"你好 Zoé")
     expected = '<text:bookmark-end text:name="%s"/>' % convert_unicode(u"你好 Zoé")
     self.assertEqual(bookmark_end.serialize(), expected)