def test_create_user_defined_3_existing(self): element = UserDefined('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>') % 'Référence' self.assertEqual(element.serialize(), expected)
def test_create_user_defined_5_nodoc(self): element = UserDefined( '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>') % 'Référence' self.assertEqual(element.serialize(), expected)
def test_create_user_defined_1(self): element = UserDefined('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_2_no_doc(self): element = UserDefined('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_4_existing(self): element = UserDefined( "Référence", value=False, # default value if not existing value_type="boolean", from_document=self.document, ) expected = ('<text:user-defined text:name="%s" ' 'office:value-type="boolean" calcext:value-type="boolean" ' 'office:boolean-value="true">true</text:user-defined>' ) % "Référence" self.assertEqual(element.serialize(), expected)
def test_create_user_defined_2(self): element = UserDefined( "unknown_in_meta2", value=datetime(2013, 12, 30), value_type="date", text="2013-12-30", style=None, from_document=self.document, ) expected = ('<text:user-defined text:name="unknown_in_meta2" ' 'office:value-type="date" calcext: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_list(self): element = UserDefined( 'Référence', value=False, # default value if not existing value_type='boolean', from_document=self.document) body = self.document.body para = body.get_paragraph() para.append(element) element2 = UserDefined('unknown_in_meta2', value=datetime(2013, 12, 30), value_type='date', text='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_get_user_defined_value(self): element = UserDefined( "Référence", value=True, # default value if not existing value_type="boolean", from_document=self.document, ) body = self.document.body para = body.get_paragraph() para.append(element) element2 = UserDefined( "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_get_user_defined(self): element = UserDefined( 'Référence', value=False, # default value if not existing value_type='boolean', from_document=self.document) body = self.document.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>') % 'Référence' self.assertEqual(user_defined.serialize(), expected)