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)