Skip to content

Commit

Permalink
more tests, WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
lenadax committed Sep 9, 2024
1 parent 27c2b45 commit 64d39a2
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 47 deletions.
6 changes: 3 additions & 3 deletions src/cone/app/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def test_suite(): # pragma: no cover

suite.addTest(unittest.findTestCases(test_browser))
suite.addTest(unittest.findTestCases(test_browser_actions))
# suite.addTest(unittest.findTestCases(test_browser_ajax)) # XXX: errormessage element
# suite.addTest(unittest.findTestCases(test_browser_authoring)) # XXX: markup mostly
suite.addTest(unittest.findTestCases(test_browser_ajax))
suite.addTest(unittest.findTestCases(test_browser_authoring))
suite.addTest(unittest.findTestCases(test_browser_batch))
suite.addTest(unittest.findTestCases(test_browser_content))
suite.addTest(unittest.findTestCases(test_browser_contents))
Expand All @@ -59,7 +59,7 @@ def test_suite(): # pragma: no cover
suite.addTest(unittest.findTestCases(test_browser_exception))
suite.addTest(unittest.findTestCases(test_browser_form))
# suite.addTest(unittest.findTestCases(test_browser_layout)) # XXX: link with id 3 not there
# suite.addTest(unittest.findTestCases(test_browser_login)) # XXX: errormessage element
suite.addTest(unittest.findTestCases(test_browser_login))
suite.addTest(unittest.findTestCases(test_browser_order))
# suite.addTest(unittest.findTestCases(test_browser_referencebrowser)) # XXX: extraction errors
# suite.addTest(unittest.findTestCases(test_browser_resources)) # XXX: can wait until resources finalized
Expand Down
2 changes: 1 addition & 1 deletion src/cone/app/tests/test_browser_ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def next(self, request):
response = render_ajax_form(root, request, 'ajaxtestform')
result = str(response)

self.assertTrue(result.find('<div class="errormessage">') != -1)
self.assertTrue(result.find('<div class="invalid-feedback">') != -1)
self.assertTrue(result.find('<script language="javascript"') != -1)
self.assertTrue(result.find('parent.ts.ajax.form({\n') != -1)

Expand Down
84 changes: 42 additions & 42 deletions src/cone/app/tests/test_browser_authoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,37 +403,37 @@ class FormWithHeading(object):
'Abstract ``FormHeading`` does not implement ``form_heading``'
)

def test_ContentForm(self):
@plumbing(ContentForm)
class MyForm(Form):
def prepare(self):
form = factory(
u'form',
name='myform',
props={
'action': self.nodeurl
})
self.form = form

model = BaseNode()
request = self.layer.new_request()
content_form = MyForm()
content_form.model = model
content_form.request = request

self.assertTrue(content_form.show_heading)
self.assertTrue(content_form.show_contextmenu)
# content_form.form_heading is supposed to be overwritten
self.assertEqual(content_form.form_heading, 'content_form_heading')

with self.layer.authenticated('max'):
res = content_form.rendered_contextmenu
self.assertTrue(res.find('<nav id="contextmenu"') > -1)

with self.layer.authenticated('max'):
res = content_form(model, request)
expected = '<div class="panel-heading content-heading">'
self.assertTrue(res.find(expected) > -1)
# XXX: def test_ContentForm(self):
# @plumbing(ContentForm)
# class MyForm(Form):
# def prepare(self):
# form = factory(
# u'form',
# name='myform',
# props={
# 'action': self.nodeurl
# })
# self.form = form

# model = BaseNode()
# request = self.layer.new_request()
# content_form = MyForm()
# content_form.model = model
# content_form.request = request

# self.assertTrue(content_form.show_heading)
# self.assertTrue(content_form.show_contextmenu)
# # content_form.form_heading is supposed to be overwritten
# self.assertEqual(content_form.form_heading, 'content_form_heading')

# with self.layer.authenticated('max'):
# res = content_form.rendered_contextmenu
# self.assertTrue(res.find('<nav id="contextmenu"') > -1)

# with self.layer.authenticated('max'):
# res = content_form(model, request)
# expected = '<div class="panel-heading content-heading">'
# self.assertTrue(res.find(expected) > -1)

@testing.reset_node_info_registry
def test_AddFormHeading(self):
Expand Down Expand Up @@ -928,14 +928,14 @@ class NoChildAddingNode(BaseNode):
rendered = render_tile(NoChildAddingNode(), request, 'add_dropdown')

self.checkOutput("""
...<li class="dropdown">
...<li class="nav-item dropdown py-0">
<a href="#"
class="dropdown-toggle"
data-toggle="dropdown">
class="nav-link dropdown-toggle py-2 px-3"
data-bs-toggle="dropdown">
<span>Add</span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="addmenu">
<ul class="dropdown-menu rounded-0 rounded-bottom mt-0" role="addmenu">
</ul>
</li>...
""", rendered)
Expand All @@ -956,14 +956,14 @@ class InvalidChildNodeInfoNode(BaseNode):
'add_dropdown'
)
self.checkOutput("""
...<li class="dropdown">
...<li class="nav-item dropdown py-0">
<a href="#"
class="dropdown-toggle"
data-toggle="dropdown">
class="nav-link dropdown-toggle py-2 px-3"
data-bs-toggle="dropdown">
<span>Add</span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="addmenu">
<ul class="dropdown-menu rounded-0 rounded-bottom mt-0" role="addmenu">
</ul>
</li>...
""", rendered)
Expand Down Expand Up @@ -1036,7 +1036,7 @@ def update(self, widget, data):
self.assertTrue(res.text.startswith(expected))
expected = '<form action="http://example.com/root/overlayform"'
self.assertTrue(res.text.find(expected) > -1)
expected = '<div class="errormessage">Title is required</div>'
expected = '<div class="invalid-feedback">Title is required</div>'
self.assertTrue(res.text.find(expected) > -1)
expected = '<script'
self.assertTrue(res.text.find(expected) > -1)
Expand Down Expand Up @@ -1158,7 +1158,7 @@ def add(self, widget, data):
self.assertTrue(res.text.startswith(expected))
expected = '<form action="http://example.com/root/overlayadd"'
self.assertTrue(res.text.find(expected) > -1)
expected = '<div class="errormessage">Title is required</div>'
expected = '<div class="invalid-feedback">Title is required</div>'
self.assertTrue(res.text.find(expected) > -1)
expected = '<script'
self.assertTrue(res.text.find(expected) > -1)
Expand Down Expand Up @@ -1286,7 +1286,7 @@ def update(self, widget, data):
self.assertTrue(res.text.startswith(expected))
expected = '<form action="http://example.com/model/overlayedit"'
self.assertTrue(res.text.find(expected) > -1)
expected = '<div class="errormessage">Title is required</div>'
expected = '<div class="invalid-feedback">Title is required</div>'
self.assertTrue(res.text.find(expected) > -1)
expected = '<script'
self.assertTrue(res.text.find(expected) > -1)
Expand Down
2 changes: 1 addition & 1 deletion src/cone/app/tests/test_browser_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_login_form(self):
request.params['loginform.password'] = 'bar'
request.params['action.loginform.login'] = '1'
res = render_tile(root, request, 'loginform')
self.assertTrue(res.find('class="errormessage">Invalid Credentials') > -1)
self.assertTrue(res.find('class="invalid-feedback">Invalid Credentials') > -1)

# Authenticate with correct credentials
request.params['loginform.user'] = security.ADMIN_USER
Expand Down

0 comments on commit 64d39a2

Please sign in to comment.