Changeset 1641
- Timestamp:
- 06/13/08 20:01:05 (21 months ago)
- Files:
-
- 1 modified
-
trunk/pylucid/tests/install_section.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pylucid/tests/install_section.py
r1634 r1641 44 44 install_url_base ="/%s" % settings.INSTALL_URL_PREFIX 45 45 46 def setUp(self):47 settings.DEBUG = True48 49 def test_prepare(self):50 """51 Check if there is no page.52 """53 self.failUnlessEqual(Page.objects.all().count(), 0)54 55 46 56 47 class TestNoPage(TestBase): … … 74 65 return response 75 66 67 def test_no_page(self): 68 """ 69 Check if there is no page. 70 """ 71 self.failUnlessEqual(Page.objects.all().count(), 0) 72 76 73 def test_page_request(self): 77 74 """ … … 191 188 192 189 193 class TestMiddlewares :#(TestBase): #DEACTIVATED!190 class TestMiddlewares(TestBase): 194 191 """ 195 192 Test the PyLucid common middleware. … … 198 195 page with some informations. 199 196 200 FIXME: How we can delete the tables? 197 TODO: Should we find a faster was to run the test without existing database 198 tables? 201 199 See: http://pylucid.org/phpBB2/viewtopic.php?p=1138#1138 202 200 … … 205 203 This messages comes from ./django/core/management/commands/flush.py 206 204 """ 207 def _rename_tables(self, old_prefix, new_prefix): 205 fixtures = [] # Run all test with a empty database 206 207 def _drop_all_tables(self): 208 # print "drop all tables...", 208 209 from django.db import connection 209 from django.core.management.sql import table_ list210 from django.core.management.sql import table_names 210 211 211 212 cursor = connection.cursor() 212 for table_name in table_list(): 213 statement = ( 214 "ALTER TABLE %(old_prefix)s%(name)s" 215 " RENAME TO %(new_prefix)s%(name)s;" 216 ) % { 217 "old_prefix": old_prefix, 218 "new_prefix": new_prefix, 219 "name": table_name, 220 } 213 for table_name in table_names(): 214 statement = u"DROP TABLE %s;" % table_name 221 215 cursor.execute(statement) 216 # print "done" 217 218 def _syncdb(self): 219 # print "syncdb...", 220 from django.core.management import call_command 221 call_command('syncdb', verbosity=0, interactive=False) 222 # print "done." 222 223 223 224 def setUp(self): 224 self._ rename_tables(old_prefix="", new_prefix="old_")225 225 self._drop_all_tables() 226 # 226 227 def tearDown(self): 227 self._ rename_tables(old_prefix="old_", new_prefix="")228 self._syncdb() 228 229 229 230 def test(self): … … 235 236 self.assertResponse(response, 236 237 must_contain=( 237 #"Can't get a database table",238 "Can't get a database table.", 238 239 "solutions", "Please read the install guide", 239 240 ), 240 #must_not_contain=("Error getting a cms page",)241 must_not_contain=("Error getting a cms page",) 241 242 ) 242 243 243 244 def test_install_section(self): 244 245 """ 245 Request the install section login. Without any database table, we should 246 be see the install secion login page. 247 """ 248 self.assertInstallSectionLogin() 246 Request the install section login. Without any database table, we 247 should be see the install secion login page. 248 """ 249 # self.assertInstallSectionLogin() 250 url = self.install_url_base 251 response = self.client.get(url) 252 self.failUnlessEqual(response.status_code, 200) 253 self.assertResponse( 254 response, 255 must_contain=("Login into the _install section",), 256 ) 249 257 250 258