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
143
Merge Requests
143
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
1dc9dd5b
Commit
1dc9dd5b
authored
Oct 11, 2022
by
Kazuhiko Shiozaki
Committed by
Jérome Perrin
Apr 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: ignore the order or attributes in HTML element assertion.
parent
32840909
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 @
1dc9dd5b
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
unittest
,
re
import
unittest
,
re
from
lxml
import
etree
from
DateTime
import
DateTime
from
DateTime
import
DateTime
import
Zope2
import
Zope2
...
@@ -122,9 +123,12 @@ class FormTestCase(unittest.TestCase):
...
@@ -122,9 +123,12 @@ class FormTestCase(unittest.TestCase):
.
manage_addField
(
'date_time'
,
'Test Field'
,
'DateTimeField'
)
.
manage_addField
(
'date_time'
,
'Test Field'
,
'DateTimeField'
)
field
=
self
.
form
.
date_time
field
=
self
.
form
.
date_time
field
.
_edit
({
'timezone_style'
:
0
})
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
})
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
):
def
test_datetime_css_class_rendering
(
self
):
...
@@ -181,13 +185,18 @@ class FormTestCase(unittest.TestCase):
...
@@ -181,13 +185,18 @@ class FormTestCase(unittest.TestCase):
.
manage_addField
(
'date_time'
,
'Test Field'
,
'DateTimeField'
)
.
manage_addField
(
'date_time'
,
'Test Field'
,
'DateTimeField'
)
field
=
self
.
form
.
date_time
field
=
self
.
form
.
date_time
field
.
_edit
({
'input_style'
:
'number'
})
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
})
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'
)})
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'
)})
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
():
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