Skip to content

Commit

Permalink
run tests on bootstrap5 theme
Browse files Browse the repository at this point in the history
  • Loading branch information
lenadax committed Nov 8, 2024
1 parent 631ae06 commit 2513cd3
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 30 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changes
1.1a3 (unreleased)
------------------

- Run tests on bootstrap5 factory theme.
[lenadax]

- ``node_info`` decorator stores name on node info instance.
[rnix]

Expand Down
4 changes: 2 additions & 2 deletions mx.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version-overrides =

main-package = -e .[test,docs]

mxmake-test-runner = zope-testrunner
mxmake-test-runner = pytest

mxmake-templates =
run-tests
Expand Down Expand Up @@ -82,7 +82,7 @@ mxmake-source-path = webresource
[yafowil]
url = ${settings:cs}/yafowil.git
pushurl = ${settings:cs_push}/yafowil.git
branch = bs5
branch = master
extras = test
mxmake-test-path = src
mxmake-source-path = src/yafowil
Expand Down
19 changes: 3 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from setuptools import find_packages
from setuptools import setup
from setuptools.command.test import test
import os


Expand All @@ -18,13 +17,6 @@ def read_file(name):
]])


class Test(test):

def run_tests(self):
from cone.app import tests
tests.run_tests()


setup(
name='cone.app',
version=version,
Expand Down Expand Up @@ -59,7 +51,7 @@ def run_tests(self):
'webresource',
'yafowil.bootstrap',
'yafowil.webob',
'yafowil>=2.3.4'
'yafowil>=3.1.1'
],
extras_require=dict(
lxml=[
Expand All @@ -71,20 +63,15 @@ def run_tests(self):
test=[
'lxml',
'yafowil.yaml',
'zope.testrunner'
'pytest',
'zope.pytestlayer'
],
docs=[
'Sphinx',
'sphinx_bootstrap_theme',
'repoze.sphinx.autointerface'
],
),
tests_require=[
'lxml',
'yafowil.yaml',
'zope.testrunner'
],
cmdclass=dict(test=Test),
entry_points="""\
[paste.app_factory]
main = cone.app:main
Expand Down
6 changes: 6 additions & 0 deletions src/cone/app/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
from pyramid.tests.test_view import DummyVenusianContext
from pyramid.tests.test_view import DummyVenusianInfo
from webob.acceptparse import create_accept_header
from yafowil.base import factory
from yafowil.bootstrap import configure_factory
from zope.component import getGlobalSiteManager
from zope.component.hooks import resetHooks
from zope.configuration.xmlconfig import XMLConfig
import cone.app
import cone.tile
import os
import venusian
import yafowil.loader # noqa


def reset_node_info_registry(fn):
Expand Down Expand Up @@ -223,9 +226,12 @@ def make_app(self, **kw):

def setUp(self, args=None):
self.make_app()
factory.push_state()
configure_factory('bootstrap5')
XMLConfig('testing/dummy_workflow.zcml', cone.app)()

def tearDown(self):
factory.pop_state()
root = get_root()
root.factories.clear()
if root.get('settings'):
Expand Down
2 changes: 1 addition & 1 deletion src/cone/app/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_suite(): # pragma: no cover
suite.addTest(unittest.findTestCases(test_browser_login))
suite.addTest(unittest.findTestCases(test_browser_order))
suite.addTest(unittest.findTestCases(test_browser_referencebrowser))
# suite.addTest(unittest.findTestCases(test_browser_resources)) # XXX: can wait until resources finalized
suite.addTest(unittest.findTestCases(test_browser_resources))
suite.addTest(unittest.findTestCases(test_browser_search))
suite.addTest(unittest.findTestCases(test_browser_settings))
suite.addTest(unittest.findTestCases(test_browser_sharing))
Expand Down
4 changes: 2 additions & 2 deletions src/cone/app/tests/test_browser_referencebrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def test_single_reference(self):
data = widget.extract(request)
self.assertEqual(
[data.value, data.extracted, data.errors],
[UNSET, '', [ExtractionError('required_message',)]]
[UNSET, '', [ExtractionError('Mandatory field was empty',)]]
)

request.params['ref'] = 'Item'
Expand Down Expand Up @@ -667,7 +667,7 @@ def test_multi_reference(self):
data = widget.extract(request)
self.assertEqual(
[data.value, data.extracted, data.errors],
[UNSET, [], [ExtractionError('required_message',)]]
[UNSET, [], [ExtractionError('Mandatory field was empty',)]]
)

request.params['ref-exists'] = 'exists'
Expand Down
4 changes: 2 additions & 2 deletions src/cone/app/tests/test_browser_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ class TestSettings(SettingsNode):
with self.layer.authenticated('manager'):
res = render_tile(settings, request, 'settings_sidebar')
self.assertTrue(res.find('id="settings_sidebar"') > -1)
self.assertTrue(res.find('class="list-group-item "') > -1)
self.assertTrue(res.find('class="list-group-item') > -1)
self.assertTrue(res.find('http://example.com/settings/test_settings') > -1)

test_settings = settings['test_settings']
with self.layer.authenticated('manager'):
res = render_tile(test_settings, request, 'settings_sidebar')
self.assertTrue(res.find('class="list-group-item selected"') > -1)
self.assertTrue(res.find('class="active list-group-item') > -1)

@testing.reset_node_info_registry
def test_SettingsContent(self):
Expand Down
12 changes: 5 additions & 7 deletions src/cone/app/tests/test_browser_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_translation_edit_renderer_no_value(self):
})

self.checkOutput("""
<div class="field mb-3" id="field-field">
<div class="field" id="field-field">
<ul class="nav nav-pills mb-2 translation-nav">
<li class="nav-item">
<a class="nav-link py-0 active" href="#translation-field-en">EN</a>
Expand All @@ -129,12 +129,10 @@ def test_translation_edit_renderer_no_value(self):
</ul>
<div class="translation-fields">
<div id="translation-field-en">
<input class="form-control" id="input-field-en" name="field.en"
type="text" value=""/>
<input class="form-control" id="input-field-en" name="field.en" type="text" value=""/>
</div>
<div id="translation-field-de">
<input class="form-control" id="input-field-de" name="field.de"
type="text" value=""/>
<input class="form-control" id="input-field-de" name="field.de" type="text" value=""/>
</div>
</div>
</div>
Expand Down Expand Up @@ -293,7 +291,7 @@ def test_required(self):
request.params['field.de'] = u'Value DE'
data = widget.extract(request)
self.checkOutput("""
<div class="field mb-3" id="field-field">
<div class="field" id="field-field">
<ul class="nav nav-pills mb-2 translation-nav">
<li class="nav-item error">
<a class="nav-link py-0 active" href="#translation-field-en">* EN</a>
Expand Down Expand Up @@ -328,7 +326,7 @@ def test_translation_display_renderer(self):
mode='display')

self.checkOutput("""
<div class="field mb-3" id="field-field">
<div class="field" id="field-field">
<ul class="nav nav-pills mb-2 translation-nav">
<li class="nav-item">
<a class="nav-link py-0 active" href="#translation-field-en">EN</a>
Expand Down

0 comments on commit 2513cd3

Please sign in to comment.