Commit 3425abf0 authored by Nicolas Delaby's avatar Nicolas Delaby

Test render_odt_variable for TextWidget, FloatWidget, IntegerWidget and DateTimeWidget.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41428 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d8b09e63
...@@ -230,6 +230,12 @@ class TestFloatField(ERP5TypeTestCase): ...@@ -230,6 +230,12 @@ class TestFloatField(ERP5TypeTestCase):
.xpath('%s/text()' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP)[0] .xpath('%s/text()' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP)[0]
self.assertEquals('1 000.0', test_value) self.assertEquals('1 000.0', test_value)
def test_render_odt_variable(self):
self.field.values['default'] = 1000.0
node = self.field.render_odt_variable(as_string=False)
self.assertEquals(node.get('{%s}value-type' % NSMAP['office']), 'float')
self.assertEquals(node.get('{%s}value' % NSMAP['office']), str(1000.0))
class TestIntegerField(ERP5TypeTestCase): class TestIntegerField(ERP5TypeTestCase):
"""Tests integer field """Tests integer field
""" """
...@@ -245,6 +251,13 @@ class TestIntegerField(ERP5TypeTestCase): ...@@ -245,6 +251,13 @@ class TestIntegerField(ERP5TypeTestCase):
self.field.values['default'] = 34 self.field.values['default'] = 34
self.assertEquals('34', self.field.render_odt(as_string=False).text) self.assertEquals('34', self.field.render_odt(as_string=False).text)
def test_render_odt_variable(self):
value = 34
self.field.values['default'] = value
node = self.field.render_odt_variable(as_string=False)
self.assertEquals(node.get('{%s}value-type' % NSMAP['office']), 'float')
self.assertEquals(node.get('{%s}value' % NSMAP['office']), str(value))
self.assertEquals(node.text, str(value))
class TestStringField(ERP5TypeTestCase): class TestStringField(ERP5TypeTestCase):
"""Tests string field """Tests string field
...@@ -275,6 +288,12 @@ class TestStringField(ERP5TypeTestCase): ...@@ -275,6 +288,12 @@ class TestStringField(ERP5TypeTestCase):
.xpath('%s/text()' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP)[0] .xpath('%s/text()' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP)[0]
self.assertEquals('Hello World!', test_value) self.assertEquals('Hello World!', test_value)
def test_render_odt_variable(self):
self.field.values['default'] = 'Hello World! <&> &lt;&mp;&gt;'
node = self.field.render_odt_variable(as_string=False)
self.assertEquals(node.get('{%s}value-type' % NSMAP['office']), 'string')
self.assertEquals(node.text, 'Hello World! <&> &lt;&mp;&gt;')
class TestDateTimeField(ERP5TypeTestCase): class TestDateTimeField(ERP5TypeTestCase):
"""Tests DateTime field """Tests DateTime field
""" """
...@@ -298,6 +317,14 @@ class TestDateTimeField(ERP5TypeTestCase): ...@@ -298,6 +317,14 @@ class TestDateTimeField(ERP5TypeTestCase):
self.field.render_odg(as_string=False)\ self.field.render_odg(as_string=False)\
.xpath('%s/text()' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP)[0]) .xpath('%s/text()' % ODG_XML_WRAPPING_XPATH, namespaces=NSMAP)[0])
def test_render_odt_variable(self):
value = DateTime(2010, 12, 06, 10, 23, 32)
self.field.values['default'] = value
node = self.field.render_odt_variable(as_string=False)
self.assertEquals(node.get('{%s}value-type' % NSMAP['office']), 'date')
self.assertEquals(node.get('{%s}date-value' % NSMAP['office']),
value.strftime('%Y-%m-%d %H:%M:%S'))
class TestTextAreaField(ERP5TypeTestCase): class TestTextAreaField(ERP5TypeTestCase):
"""Tests TextArea field """Tests TextArea field
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment