[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/Browser/tests - testAttributePublisher.py:1.1.2.6
Martijn Pieters
mj@zope.com
Tue, 27 Nov 2001 14:59:45 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv8373/lib/python/Zope/Publisher/Browser/tests
Modified Files:
Tag: Zope-3x-branch
testAttributePublisher.py
Log Message:
Refactored AttributePublisher tests for understanding, clarity and
maintainability. Added one test for a raised exception.
=== Zope3/lib/python/Zope/Publisher/Browser/tests/testAttributePublisher.py 1.1.2.5 => 1.1.2.6 ===
class Presentation(AttributePublisher):
-
- def index(self): return 'index'
- def action(self): return 'action'
-
-class Test(unittest.TestCase):
-
- def testItAll(self):
- o=Presentation()
-
- self.assertEquals( o.browser_default(None)
- , ( o, ('index.html',) )
- )
- self.assertEquals( o.browser_traverse(None, 'index.html')()
- , 'index'
- )
- self.assertEquals( o.browser_traverse(None, 'index')()
- , 'index'
- )
- self.assertEquals( o.browser_traverse(None, 'action.html')()
- , 'action'
- )
- self.assertEquals( o.browser_traverse(None, 'action')()
- , 'action'
- )
+ index = 'index'
+ action = 'action'
+ foo = 'foo'
+
+class TestAttributePublisher(unittest.TestCase):
+ def setUp(self):
+ self.pres = Presentation()
+
+ def testBrowserDefault(self):
+ self.assertEquals(self.pres.browser_default(None),
+ (self.pres, ('index.html',)))
+
+ def testBrowserTraverseIndexHtml(self):
+ self.assertEquals(self.pres.browser_traverse(None, 'index.html'),
+ 'index')
+
+ def testBrowserTraverseIndex(self):
+ self.assertEquals(self.pres.browser_traverse(None, 'index'),
+ 'index')
+
+ def testBrowserTraverseActionHtml(self):
+ self.assertEquals(self.pres.browser_traverse(None, 'action.html'),
+ 'action')
+
+ def testBrowserTraverseAction(self):
+ self.assertEquals(self.pres.browser_traverse(None, 'action'),
+ 'action')
+
+ def testBrowserTraverseNotFound(self):
+ self.failUnlessRaises(AttributeError, self.pres.browser_traverse,
+ None, 'bar')
def test_suite():
loader=unittest.TestLoader()
- return loader.loadTestsFromTestCase(Test)
+ return loader.loadTestsFromTestCase(TestAttributePublisher)
if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())