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)
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)
def test_create_variable_set_datetime(self): date = datetime(2009, 5, 17, 23, 23, 00) variable_set = odf_create_variable_set('你好 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('你好 Zoé') self.assertEqual(variable_set.serialize(), expected)
def test_with_variable(self): variable_set = odf_create_variable_set('你好 Zoé', 42) set_value(variable_set, '你好 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('你好 Zoé'),) * 3) self.assertEqual(variable_set.serialize(), expected)
area='text', background_color=rgb2hex('yellow')) document.insert_style(style) # The paragraph text = (u'The office document file format OpenDocument Format (ODF) ' u'is an ISO standard ISO 26300 used by many applications.') paragraph = odf_create_paragraph(text, u"Standard") paragraph.set_span(u"style2", regex=u"ISO standard") body.append(paragraph) # 6- A variable # ------------- # A variable "spam" with the value 42 variable_set = odf_create_variable_set('spam', 42) value_type = variable_set.get_attribute('office:value-type') variable_decl = odf_create_variable_decl('spam', value_type) # Insert heading = odf_create_heading(1, text=u'A variable') body.append(heading) decl = body.get_variable_decls() decl.append(variable_decl) text = u'Set of spam.' paragraph = odf_create_paragraph(text, style=u"Standard") body.append(paragraph) paragraph._insert_between(variable_set, u"Set", u"spam.")
background_color=rgb2hex('yellow')) document.insert_style(style) # The paragraph text = (u'The office document file format OpenDocument Format (ODF) ' u'is an ISO standard ISO 26300 used by many applications.') paragraph = odf_create_paragraph(text, u"Standard") paragraph.set_span(u"style2", regex=u"ISO standard") body.append(paragraph) # 4- A variable # ------------- # A variable "spam" with the value 42 variable_set = odf_create_variable_set('spam', 42) value_type = variable_set.get_attribute('office:value-type') variable_decl = odf_create_variable_decl('spam', value_type) # Insert heading = odf_create_heading(1, text=u'A variable') body.append(heading) decl = body.get_variable_decls() decl.append(variable_decl) text = u'Set of spam.' paragraph = odf_create_paragraph(text, style=u"Standard") body.append(paragraph) paragraph._insert_between(variable_set, u"Set", u"spam.")
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)
def test_with_variable(self): variable_set = odf_create_variable_set(u'你好 Zoé', 42) self.assertEqual(get_value(variable_set), 42)
def test_create_variable_set_float(self): variable_set = odf_create_variable_set('你好 Zoé', value=42) expected = ('<text:variable-set text:name="%s" ' 'office:value-type="float" office:value="42" ' 'text:display="none"/>') % convert_unicode('你好 Zoé') self.assertEqual(variable_set.serialize(), expected)
def test_with_variable(self): variable_set = odf_create_variable_set('你好 Zoé', 42) self.assertEqual(get_value(variable_set), 42)