Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
3759f70e
Commit
3759f70e
authored
Oct 11, 2022
by
Kazuhiko Shiozaki
Committed by
Jérome Perrin
Dec 28, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: ignore the order or attributes in HTML element assertion.
parent
797bbb84
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
product/Formulator/tests/testForm.py
product/Formulator/tests/testForm.py
+15
-6
No files found.
product/Formulator/tests/testForm.py
View file @
3759f70e
# -*- 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
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment