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
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
86c73d60
Commit
86c73d60
authored
Oct 11, 2022
by
Kazuhiko Shiozaki
Committed by
Jérome Perrin
Mar 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: ignore the order or attributes in HTML element assertion.
parent
e31f3284
Changes
1
Hide 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 @
86c73d60
# -*- 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