From: Stefan H. H. <sh...@us...> - 2004-01-14 15:27:53
|
Update of /cvsroot/collective/ZopeTestCase In directory sc8-pr-cvs1:/tmp/cvs-serv19985 Modified Files: testWebserver.py Log Message: Rename tests to improve readability. Index: testWebserver.py =================================================================== RCS file: /cvsroot/collective/ZopeTestCase/testWebserver.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- testWebserver.py 11 Jan 2004 23:09:18 -0000 1.9 +++ testWebserver.py 14 Jan 2004 15:27:50 -0000 1.10 @@ -82,29 +82,29 @@ # Commit after cleanup get_transaction().commit() - def testAccessPublic(self): + def testAccessPublicObject(self): # Test access to a public resource page = self.folder.index_html(self.folder) self.assertEqual(page, 'index_html called') - def testWebAccessPublic(self): + def testURLAccessPublicObject(self): # Test web access to a public resource urllib._urlopener = ManagementOpener() page = urllib.urlopen(folder_url+'/index_html').read() self.assertEqual(page, 'index_html called') - def testAccessProtected(self): + def testAccessProtectedObject(self): # Test access to a protected resource page = self.folder.secret_html(self.folder) self.assertEqual(page, 'secret_html called') - def testWebAccessProtected(self): + def testURLAccessProtectedObject(self): # Test web access to a protected resource urllib._urlopener = ManagementOpener() page = urllib.urlopen(folder_url+'/secret_html').read() self.assertEqual(page, 'secret_html called') - def testSecurityPublic(self): + def testSecurityOfPublicObject(self): # Test security of a public resource try: self.folder.restrictedTraverse('index_html') @@ -112,19 +112,16 @@ # Convert error to failure self.fail('Unauthorized') - def testWebSecurityPublic(self): + def testURLSecurityOfPublicObject(self): # Test web security of a public resource urllib._urlopener = UnauthorizedOpener() try: - page = urllib.urlopen(folder_url+'/index_html').read() + urllib.urlopen(folder_url+'/index_html') except Unauthorized: # Convert error to failure self.fail('Unauthorized') - else: - if page.find('Resource not found') >= 0: - self.fail('Resource not found') - def testSecurityProtected(self): + def testSecurityOfProtectedObject(self): # Test security of a protected resource try: self.folder.restrictedTraverse('secret_html') @@ -133,27 +130,24 @@ else: self.fail('Resource not protected') - def testWebSecurityProtected(self): + def testURLSecurityOfProtectedObject(self): # Test web security of a protected resource urllib._urlopener = UnauthorizedOpener() try: - page = urllib.urlopen(folder_url+'/secret_html').read() + urllib.urlopen(folder_url+'/secret_html') except Unauthorized: pass # Test passed else: - if page.find('Resource not found') >= 0: - self.fail('Resource not found') - else: - self.fail('Resource not protected') + self.fail('Resource not protected') def testModifyObject(self): - # Test object modification + # Test a script that modifies the ZODB self.setRoles(['Manager']) page = self.folder.object.change_title(self.folder.object, self.app.REQUEST) self.assertEqual(page, 'Foo') self.assertEqual(self.folder.object.title, 'Foo') - def testWebModifyObject(self): + def testURLModifyObject(self): # Test a transaction that actually commits something urllib._urlopener = ManagementOpener() page = urllib.urlopen(folder_url+'/object/change_title').read() @@ -166,17 +160,18 @@ class TestSandboxedWebserver(ZopeTestCase.Sandboxed, TestWebserver): '''Demonstrates that tests involving ZServer threads can also be - run from sandboxes. In fact, it may even be preferable to do so. + run from sandboxes. In fact, it may be preferable to do so. ''' # Note: By inheriting from TestWebserver we run the same # test methods as above! - def testWebModifyObject(self): - TestWebserver.testWebModifyObject(self) + def testConnectionIsShared(self): # Due to sandboxing the ZServer thread operates on the # same connection as the main thread, allowing us to - # see the changes made to 'object' right away. + # see changes made to 'object' right away. + urllib._urlopener = ManagementOpener() + urllib.urlopen(folder_url+'/object/change_title') self.assertEqual(self.folder.object.title, 'Foo') |