fix: add "other" menu entry, plus docs/tests
This commit is contained in:
parent
ce54ca6bd6
commit
c2f76f6c97
20 changed files with 546 additions and 15 deletions
32
tests/web/test_app.py
Normal file
32
tests/web/test_app.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from wuttjamaican.testing import FileTestCase, ConfigTestCase
|
||||
|
||||
from asgiref.wsgi import WsgiToAsgi
|
||||
from pyramid.router import Router
|
||||
|
||||
from sideshow_corepos.web import app as mod
|
||||
|
||||
|
||||
class TestMain(FileTestCase):
|
||||
|
||||
def test_basic(self):
|
||||
global_config = None
|
||||
myconf = self.write_file('my.conf', '')
|
||||
settings = {'wutta.config': myconf}
|
||||
app = mod.main(global_config, **settings)
|
||||
self.assertIsInstance(app, Router)
|
||||
|
||||
|
||||
class TestMakeWsgiApp(ConfigTestCase):
|
||||
|
||||
def test_basic(self):
|
||||
wsgi = mod.make_wsgi_app()
|
||||
self.assertIsInstance(wsgi, Router)
|
||||
|
||||
|
||||
class TestMakeAsgiApp(ConfigTestCase):
|
||||
|
||||
def test_basic(self):
|
||||
asgi = mod.make_asgi_app()
|
||||
self.assertIsInstance(asgi, WsgiToAsgi)
|
11
tests/web/test_init.py
Normal file
11
tests/web/test_init.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from wuttaweb.testing import WebTestCase
|
||||
|
||||
from sideshow_corepos import web as mod
|
||||
|
||||
|
||||
class TestIncludeme(WebTestCase):
|
||||
|
||||
def test_coverage(self):
|
||||
mod.includeme(self.pyramid_config)
|
51
tests/web/test_menus.py
Normal file
51
tests/web/test_menus.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from wuttaweb.testing import WebTestCase
|
||||
|
||||
from sideshow_corepos.web import menus as mod
|
||||
|
||||
|
||||
class TestSideshowMenuHandler(WebTestCase):
|
||||
|
||||
def make_handler(self):
|
||||
return mod.SideshowMenuHandler(self.config)
|
||||
|
||||
def test_make_customers_menu(self):
|
||||
handler = self.make_handler()
|
||||
menu = handler.make_customers_menu(self.request)
|
||||
item = menu['items'][-1]
|
||||
self.assertEqual(item, {
|
||||
'title': "CORE-POS Members",
|
||||
'route': 'corepos_members',
|
||||
'perm': 'corepos_members.list',
|
||||
})
|
||||
|
||||
def test_make_products_menu(self):
|
||||
handler = self.make_handler()
|
||||
menu = handler.make_products_menu(self.request)
|
||||
item = menu['items'][-1]
|
||||
self.assertEqual(item, {
|
||||
'title': "CORE-POS Products",
|
||||
'route': 'corepos_products',
|
||||
'perm': 'corepos_products.list',
|
||||
})
|
||||
|
||||
def test_make_other_menu(self):
|
||||
handler = self.make_handler()
|
||||
|
||||
# no url configured by default
|
||||
menu = handler.make_other_menu(self.request)
|
||||
if menu['items']:
|
||||
item = menu['items'][-1]
|
||||
self.assertNotEqual(item['title'], "CORE Office")
|
||||
|
||||
# entry added if url configured
|
||||
self.config.setdefault('corepos.office.url', 'http://localhost/fannie/')
|
||||
menu = handler.make_other_menu(self.request)
|
||||
item = menu['items'][-1]
|
||||
self.assertEqual(item, {
|
||||
'title': "CORE Office",
|
||||
# nb. trailing slash gets stripped
|
||||
'url': 'http://localhost/fannie',
|
||||
'target': '_blank',
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue