Commit 135577f3 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Arnaud Fontaine

test: ignore the order or attributes in HTML element assertion.

parent cfbf6611
# -*- coding: utf-8 -*-
import unittest, re
from lxml import etree
from DateTime import DateTime
import Zope2
......@@ -122,9 +123,12 @@ class FormTestCase(unittest.TestCase):
.manage_addField('date_time','Test Field','DateTimeField')
field = self.form.date_time
field._edit({'timezone_style': 0})
self.assertNotIn('<select size="1" name="subfield_field_date_time_timezone" >', field.render())
parser = etree.HTMLParser()
e = etree.fromstring(field.render(), parser=parser)
self.assertFalse(e.xpath('//select[@size="1"][@name="subfield_field_date_time_timezone"]'))
field._edit({'timezone_style': 1})
self.assertIn('<select size="1" name="subfield_field_date_time_timezone" >', field.render())
e = etree.fromstring(field.render(), parser=parser)
self.assertTrue(e.xpath('//select[@size="1"][@name="subfield_field_date_time_timezone"]'))
def test_datetime_css_class_rendering(self):
......@@ -181,13 +185,18 @@ class FormTestCase(unittest.TestCase):
.manage_addField('date_time','Test Field','DateTimeField')
field = self.form.date_time
field._edit({'input_style': 'number'})
self.assertIn('<input name="subfield_field_date_time_year" value="" maxlength="4" type="number" size="4" min="0" max="9999" />', field.render())
parser = etree.HTMLParser()
e = etree.fromstring(field.render(), parser=parser)
self.assertTrue(e.xpath('//input[@name="subfield_field_date_time_year"][@value=""][@maxlength="4"][@type="number"][@size="4"][@min="0"][@max="9999"]'))
field._edit({'start_datetime': DateTime('1900/01/01'), 'end_datetime': None})
self.assertIn('<input name="subfield_field_date_time_year" value="" maxlength="4" type="number" size="4" min="1900" max="9999" />', field.render())
e = etree.fromstring(field.render(), parser=parser)
self.assertTrue(e.xpath('//input[@name="subfield_field_date_time_year"][@value=""][@maxlength="4"][@type="number"][@size="4"][@min="1900"][@max="9999"]'))
field._edit({'start_datetime': None, 'end_datetime': DateTime('2099/12/31')})
self.assertIn('<input name="subfield_field_date_time_year" value="" maxlength="4" type="number" size="4" min="0" max="2099" />', field.render())
e = etree.fromstring(field.render(), parser=parser)
self.assertTrue(e.xpath('//input[@name="subfield_field_date_time_year"][@value=""][@maxlength="4"][@type="number"][@size="4"][@min="0"][@max="2099"]'))
field._edit({'start_datetime': DateTime('1900/01/01'), 'end_datetime': DateTime('2099/12/31')})
self.assertIn('<input name="subfield_field_date_time_year" value="" maxlength="4" type="number" size="4" min="1900" max="2099" />', field.render())
e = etree.fromstring(field.render(), parser=parser)
self.assertTrue(e.xpath('//input[@name="subfield_field_date_time_year"][@value=""][@maxlength="4"][@type="number"][@size="4"][@min="1900"][@max="2099"]'))
def test_suite():
......
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