def test_get_user_defined_list(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) element2 = odf_create_user_defined(u'unknown_in_meta2', value=datetime(2013, 12, 30), value_type=u'date', text=u'2013-12-30', style=None, from_document=None) para.append(element2) user_defined_list = body.get_user_defined_list() self.assertEqual(len(user_defined_list), 2)
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)
def test_get_user_defined_value(self): element = odf_create_user_defined('Référence', value=False, # default value if not existing value_type='boolean', from_document=self.document) body = self.document.get_body() para = body.get_paragraph() para.append(element) element2 = odf_create_user_defined('unknown_in_meta2', value=datetime(2013, 12, 30), value_type='date', text='2013-12-30', style=None, from_document=None) para.append(element2) value = body.get_user_defined_value('Référence') self.assertEqual(value, True) value = body.get_user_defined_value('unknown_in_meta2') self.assertEqual(value, datetime(2013, 12, 30))
def test_create_user_defined_5_nodoc(self): element = odf_create_user_defined('Référence', value=False, # default value if not existing value_type='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('Référence') self.assertEqual(element.serialize(), expected)
def test_create_user_defined_1(self): element = odf_create_user_defined('unknown_in_meta', value=42, value_type='float', text=None, style=None, from_document=self.document) expected = ('<text:user-defined text:name="unknown_in_meta" ' 'office:value-type="float" ' 'office:value="42">42</text:user-defined>') self.assertEqual(element.serialize(), expected)
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)
def test_create_user_defined_1(self): element = odf_create_user_defined(u'unknown_in_meta', value=42, value_type=u'float', text=None, style=None, from_document=self.document) expected = ('<text:user-defined text:name="unknown_in_meta" ' 'office:value-type="float" ' 'office:value="42">42</text:user-defined>') self.assertEqual(element.serialize(), expected)
def test_create_user_defined_2_no_doc(self): element = odf_create_user_defined('unknown_in_meta2', value=datetime(2013, 12, 30), value_type='date', text='2013-12-30', style=None, from_document=None) expected = ('<text:user-defined text:name="unknown_in_meta2" ' 'office:value-type="date" ' 'office:date-value="2013-12-30T00:00:00">2013-12-30' '</text:user-defined>') self.assertEqual(element.serialize(), expected)
def test_create_user_defined_2_no_doc(self): element = odf_create_user_defined(u'unknown_in_meta2', value=datetime(2013, 12, 30), value_type=u'date', text=u'2013-12-30', style=None, from_document=None) expected = ('<text:user-defined text:name="unknown_in_meta2" ' 'office:value-type="date" ' 'office:date-value="2013-12-30T00:00:00">2013-12-30' '</text:user-defined>') self.assertEqual(element.serialize(), expected)
def test_get_user_defined(self): element = odf_create_user_defined('Référence', value=False, # default value if not existing value_type='boolean', from_document=self.document) body = self.document.get_body() para = body.get_paragraph() para.append(element) user_defined = body.get_user_defined('Référence') expected = ( '<text:user-defined text:name="%s" ' 'office:value-type="boolean" ' 'office:boolean-value="true">' 'true</text:user-defined>') % convert_unicode('Référence') self.assertEqual(user_defined.serialize(), expected)
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)