Exemplo n.º 1
0
class TestMultiListField(ERP5TypeTestCase):
    def afterSetUp(self):
        self.field = MultiListField("test_field")
        self.widget = self.field.widget
        self.field.values["items"] = [("A", "a"), ("B", "b")]
        self.field.values["default"] = ["a", "b"]

    def test_render_view(self):
        self.assertEqual("A<br />\nB", self.field.render_view(value=["a", "b"]))

    def test_render_odt(self):
        element = self.field.render_odt(as_string=False)
        self.assertEqual("{%(text)s}p" % NSMAP, element.tag)
        # separated by text:line-break
        self.assertEqual("{%(text)s}line-break" % NSMAP, element[0].tag)
        self.assertEqual(["A", "B"], [x for x in element.itertext()])

    def test_render_odt_view(self):
        element = self.field.render_odt_view(as_string=False, value=["a", "b"], REQUEST=self.portal.REQUEST)
        self.assertEqual("{%(text)s}p" % NSMAP, element.tag)
        # separated by text:line-break
        self.assertEqual("{%(text)s}line-break" % NSMAP, element[0].tag)
        self.assertEqual(["A", "B"], [x for x in element.itertext()])

        # values not in items are displayed with ???
        element = self.field.render_odt_view(as_string=False, value=["other"], REQUEST=self.portal.REQUEST)
        self.assertEqual("{%(text)s}p" % NSMAP, element.tag)
        self.assertEqual("??? (other)", element.text)
Exemplo n.º 2
0
class TestMultiListField(ERP5TypeTestCase):

  def afterSetUp(self):
    self.field = MultiListField('test_field')
    self.widget = self.field.widget
    self.field.values['items'] = [('A', 'a',), ('B', 'b')]
    self.field.values['default'] = ['a', 'b']

  def test_render_view(self):
    self.assertEquals('A<br />\nB', self.field.render_view(value=['a', 'b']))

  def test_render_odt(self):
    element = self.field.render_odt(as_string=False)
    self.assertEquals('{%(text)s}p' % NSMAP, element.tag)
    # separated by text:line-break
    self.assertEquals('{%(text)s}line-break' % NSMAP, element[0].tag)
    self.assertEquals(['A', 'B'], [x for x in element.itertext()])

  def test_render_odt_view(self):
    element = self.field.render_odt_view(as_string=False,
                                        value=['a', 'b'],
                                        REQUEST=self.portal.REQUEST)
    self.assertEquals('{%(text)s}p' % NSMAP, element.tag)
    # separated by text:line-break
    self.assertEquals('{%(text)s}line-break' % NSMAP, element[0].tag)
    self.assertEquals(['A', 'B'], [x for x in element.itertext()])

    # values not in items are displayed with ???
    element = self.field.render_odt_view(as_string=False,
                                        value=['other'],
                                        REQUEST=self.portal.REQUEST)
    self.assertEquals('{%(text)s}p' % NSMAP, element.tag)
    self.assertEquals('??? (other)', element.text)
Exemplo n.º 3
0
class TestMultiListField(ERP5TypeTestCase):

  def afterSetUp(self):
    self.field = MultiListField('test_field')
    self.widget = self.field.widget
    self.field.values['items'] = [('A', 'a',), ('B', 'b')]
    self.field.values['default'] = ['a', 'b']

  def test_render_view(self):
    self.assertEqual('A<br />\nB', self.field.render_view(value=['a', 'b']))

  def test_render_odt(self):
    element = self.field.render_odt(as_string=False)
    self.assertEqual('{%(text)s}p' % NSMAP, element.tag)
    # separated by text:line-break
    self.assertEqual('{%(text)s}line-break' % NSMAP, element[0].tag)
    self.assertEqual(['A', 'B'], [x for x in element.itertext()])

  def test_render_odt_view(self):
    element = self.field.render_odt_view(as_string=False,
                                        value=['a', 'b'],
                                        REQUEST=self.portal.REQUEST)
    self.assertEqual('{%(text)s}p' % NSMAP, element.tag)
    # separated by text:line-break
    self.assertEqual('{%(text)s}line-break' % NSMAP, element[0].tag)
    self.assertEqual(['A', 'B'], [x for x in element.itertext()])

    # values not in items are displayed with ???
    element = self.field.render_odt_view(as_string=False,
                                        value=['other'],
                                        REQUEST=self.portal.REQUEST)
    self.assertEqual('{%(text)s}p' % NSMAP, element.tag)
    self.assertEqual('??? (other)', element.text)
Exemplo n.º 4
0
 def afterSetUp(self):
     self.field = MultiListField('test_field')
     self.widget = self.field.widget
     self.field.values['items'] = [(
         'A',
         'a',
     ), ('B', 'b')]
     self.field.values['default'] = ['a', 'b']
Exemplo n.º 5
0
 def afterSetUp(self):
     self.field = MultiListField("test_field")
     self.widget = self.field.widget
     self.field.values["items"] = [("A", "a"), ("B", "b")]
     self.field.values["default"] = ["a", "b"]
Exemplo n.º 6
0
 def afterSetUp(self):
   self.field = MultiListField('test_field')
   self.widget = self.field.widget
   self.field.values['items'] = [('A', 'a',), ('B', 'b')]
   self.field.values['default'] = ['a', 'b']