basic setup for menu.py and unit testing
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@541 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
e96ed17b32
commit
845ae56cf3
6 changed files with 126 additions and 0 deletions
BIN
cyc-logo02.png
BIN
cyc-logo02.png
Binary file not shown.
Before Width: | Height: | Size: 6.7 KiB |
7
doc/menu.txt
Normal file
7
doc/menu.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
Creating and Rendering Menus
|
||||||
|
============================
|
||||||
|
|
||||||
|
We first set up a test environment:
|
||||||
|
|
||||||
|
>>> from zope.app.testing import ztapi
|
||||||
|
|
34
interfaces.py
Normal file
34
interfaces.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2005 Helmut Merz helmutm@cy55.de
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
cybertools interface definitions.
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
||||||
|
from zope.interface import Interface
|
||||||
|
from zope.app.container.interfaces import IOrderedContainer
|
||||||
|
|
||||||
|
from zope.schema import Text, TextLine, List, Object, Int
|
||||||
|
|
||||||
|
|
||||||
|
class IMenu(Interface):
|
||||||
|
""" A Menu.
|
||||||
|
"""
|
||||||
|
|
35
menu.py
Normal file
35
menu.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2005 Helmut Merz helmutm@cy55.de
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
Definition of the Menu class.
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
||||||
|
from zope.interface import implements
|
||||||
|
from zope.app.container.ordered import OrderedContainer
|
||||||
|
from zope.app import zapi
|
||||||
|
|
||||||
|
from interfaces import IMenu
|
||||||
|
|
||||||
|
class Menu(OrderedContainer):
|
||||||
|
|
||||||
|
implements(IMenu)
|
||||||
|
|
||||||
|
title = u''
|
4
tests/__init__.py
Normal file
4
tests/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
"""
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
46
tests/test_cybertools.py
Executable file
46
tests/test_cybertools.py
Executable file
|
@ -0,0 +1,46 @@
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from zope.testing.doctestunit import DocFileSuite
|
||||||
|
from zope.app.testing import ztapi
|
||||||
|
from zope.interface.verify import verifyClass
|
||||||
|
#from zope.app.tests.setup import placelessSetUp
|
||||||
|
from zope.app.testing.setup import placefulSetUp
|
||||||
|
from zope.app.container.interfaces import IContained
|
||||||
|
from zope.app.folder import Folder
|
||||||
|
from zope.app import zapi
|
||||||
|
|
||||||
|
from cybertools.menu import Menu
|
||||||
|
from cybertools.interfaces import IMenu
|
||||||
|
|
||||||
|
class TestMenu(unittest.TestCase):
|
||||||
|
"Test methods of the Menu class."
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
# placelessSetUp()
|
||||||
|
placefulSetUp()
|
||||||
|
self.f1 = Folder()
|
||||||
|
self.f1.__name__ = u'f1'
|
||||||
|
self.m1 = Menu()
|
||||||
|
self.f1['m1'] = self.m1
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# the tests...
|
||||||
|
|
||||||
|
def testInterface(self):
|
||||||
|
self.assert_(IMenu.providedBy(Menu()),
|
||||||
|
'Interface IMenu is not implemented by class Menu.')
|
||||||
|
self.assert_(IContained.providedBy(Menu()),
|
||||||
|
'Interface IContained is not implemented by class Menu.')
|
||||||
|
verifyClass(IMenu, Menu)
|
||||||
|
|
||||||
|
def test_suite():
|
||||||
|
return unittest.TestSuite((
|
||||||
|
unittest.makeSuite(TestMenu),
|
||||||
|
DocFileSuite('../doc/menu.txt'),
|
||||||
|
))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(defaultTest='test_suite')
|
Loading…
Add table
Reference in a new issue