Changeset 6961 for main/waeup.sirp/trunk/src/waeup/sirp/hostels
- Timestamp:
- 28 Oct 2011, 05:34:33 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/hostels/tests.py
r6951 r6961 15 15 ## 16 16 """ 17 Tests for hostels. 17 Tests for hostels. and their UI components 18 18 """ 19 import shutil 20 import tempfile 19 21 from zope.interface.verify import verifyClass, verifyObject 22 from zope.component.hooks import setSite, clearSite 23 from zope.testbrowser.testing import Browser 24 from zope.security.interfaces import Unauthorized 25 from waeup.sirp.app import University 20 26 from waeup.sirp.hostels.interfaces import ( 21 27 IHostelsContainer, IHostel) … … 55 61 self.assertRaises( 56 62 NotImplementedError, container.clear) 63 64 class HostelsFullSetup(FunctionalTestCase): 65 66 def setUp(self): 67 super(HostelsFullSetup, self).setUp() 68 69 # Setup a sample site for each test 70 app = University() 71 self.dc_root = tempfile.mkdtemp() 72 app['datacenter'].setStoragePath(self.dc_root) 73 74 # Prepopulate the ZODB... 75 self.getRootFolder()['app'] = app 76 # we add the site immediately after creation to the 77 # ZODB. Catalogs and other local utilities are not setup 78 # before that step. 79 self.app = self.getRootFolder()['app'] 80 # Set site here. Some of the following setup code might need 81 # to access grok.getSite() and should get our new app then 82 setSite(app) 83 84 self.container_path = 'http://localhost/app/hostels' 85 self.manage_container_path = self.container_path + '/@@manage' 86 self.add_hostel_path = self.container_path + '/addhostel' 87 88 # Put the prepopulated site into test ZODB and prepare test 89 # browser 90 self.browser = Browser() 91 self.browser.handleErrors = False 92 93 def tearDown(self): 94 super(HostelsFullSetup, self).tearDown() 95 clearSite() 96 shutil.rmtree(self.dc_root) 97 98 class HostelsUITests(HostelsFullSetup): 99 100 layer = FunctionalLayer 101 102 def test_anonymous_access(self): 103 # Anonymous users can't access hostels containers 104 self.assertRaises( 105 Unauthorized, self.browser.open, self.manage_container_path) 106 return 107 108 def test_add_search_delete_hostels(self): 109 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 110 self.browser.open(self.container_path) 111 self.browser.getLink("Manage accommodation").click() 112 self.assertEqual(self.browser.headers['Status'], '200 Ok') 113 self.assertEqual(self.browser.url, self.manage_container_path) 114 self.browser.getControl("Add hostel").click() 115 self.assertEqual(self.browser.headers['Status'], '200 Ok') 116 self.assertEqual(self.browser.url, self.add_hostel_path) 117 self.browser.getControl("Create hostel").click() 118 self.assertEqual(self.browser.headers['Status'], '200 Ok') 119 self.assertTrue('Hostel created' in self.browser.contents) 120 #import pdb; pdb.set_trace() 121 hall = self.app['hostels']['hall_1'] 122 hall.blocks_for_female = ['A','B'] 123 self.browser.open(self.container_path + '/hall_1') 124 expected = '''...<ul id="form.blocks_for_female" ><li>Block A</li> 125 <li>Block B</li></ul>...''' 126 self.assertMatches(expected,self.browser.contents) 127 self.browser.open(self.container_path + '/hall_1/edit')
Note: See TracChangeset for help on using the changeset viewer.