summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zielinski <tomasz.zielinski@pyconsultant.eu>2011-12-13 23:18:09 +0100
committerTomasz Zielinski <tomasz.zielinski@pyconsultant.eu>2011-12-13 23:18:09 +0100
commitdb0cfbacd3abfb64d50d51183d0fa00b6d9bd9a6 (patch)
treee2f73bdfe2b86236bfe5f537d362a1be1bec4fcb
parent4cd8037ca1add201f9f0a11654588094e39b06c8 (diff)
downloadaskbot-db0cfbacd3abfb64d50d51183d0fa00b6d9bd9a6.tar.gz
askbot-db0cfbacd3abfb64d50d51183d0fa00b6d9bd9a6.tar.bz2
askbot-db0cfbacd3abfb64d50d51183d0fa00b6d9bd9a6.zip
Healing test suite
-rw-r--r--askbot/migrations/0088_install__post_view__for__development.py2
-rw-r--r--askbot/tests/page_load_tests.py27
-rw-r--r--askbot/tests/utils.py39
3 files changed, 43 insertions, 25 deletions
diff --git a/askbot/migrations/0088_install__post_view__for__development.py b/askbot/migrations/0088_install__post_view__for__development.py
index 1066dc5d..a5439154 100644
--- a/askbot/migrations/0088_install__post_view__for__development.py
+++ b/askbot/migrations/0088_install__post_view__for__development.py
@@ -13,7 +13,7 @@ class Migration(SchemaMigration):
askbot.get_path_to('models/post_view.sql')
).read()
import warnings
- warnings.filterwarnings("ignore", "Unknown table 'askbot.askbot_post'") # DROP VIEW might raise a warning so let's filter that out
+ warnings.filterwarnings("ignore", "Unknown table .*?\.askbot_post'") # DROP VIEW might raise a warning so let's filter that out
db.execute('DROP VIEW IF EXISTS askbot_post')
db.execute(create_post_view_sql)
diff --git a/askbot/tests/page_load_tests.py b/askbot/tests/page_load_tests.py
index 8cebb602..318e42e8 100644
--- a/askbot/tests/page_load_tests.py
+++ b/askbot/tests/page_load_tests.py
@@ -36,14 +36,25 @@ if CMAJOR == 0 and CMINOR == 3 and CMICRO < 4:
class PageLoadTestCase(AskbotTestCase):
- if getattr(settings, 'ASKBOT_FAST_TESTS', False) == True:
- fixtures = [ os.path.join(os.path.dirname(__file__), 'test_data.json'),]
- def setUp(self):
- if getattr(settings, 'ASKBOT_FAST_TESTS', False) == True:
- return
- else:
- from django.core import management
- management.call_command('askbot_add_test_content', verbosity=0, interactive=False)
+
+ def _fixture_setup(self):
+ from django.core import management
+ management.call_command('askbot_add_test_content', verbosity=0, interactive=False)
+ super(PageLoadTestCase, self)._fixture_setup()
+
+ def _fixture_teardown(self):
+ super(PageLoadTestCase, self)._fixture_teardown()
+ from django.core import management
+ management.call_command('flush', verbosity=0, interactive=False)
+
+# if getattr(settings, 'ASKBOT_FAST_TESTS', False) == True:
+# fixtures = [ os.path.join(os.path.dirname(__file__), 'test_data.json'),]
+# def setUp(self):
+# if getattr(settings, 'ASKBOT_FAST_TESTS', False) == True:
+# return
+# else:
+# from django.core import management
+# management.call_command('askbot_add_test_content', verbosity=0, interactive=False)
def try_url(
self,
diff --git a/askbot/tests/utils.py b/askbot/tests/utils.py
index 218e9c4d..182b7768 100644
--- a/askbot/tests/utils.py
+++ b/askbot/tests/utils.py
@@ -61,22 +61,29 @@ class AskbotTestCase(TestCase):
"""adds some askbot-specific methods
to django TestCase class
"""
-
- def _fixture_setup(self):
- # HACK: Create askbot_post database VIEW for the purpose of performing tests
- import os.path
- from django.conf import settings
- from django.db import connection
- sql = open(os.path.join(settings.PROJECT_ROOT, 'askbot', 'models', 'post_view.sql'), 'rt').read()
- cursor = connection.cursor()
- cursor.execute(sql)
- super(AskbotTestCase, self)._fixture_setup()
-
- def _fixture_teardown(self):
- super(AskbotTestCase, self)._fixture_teardown()
- from django.db import connection
- cursor = connection.cursor()
- cursor.execute('DROP VIEW IF EXISTS askbot_post')
+# INFO: This fixture has been replaced by migration 0088 (and possibly some subsequent ones)
+# Therefore we should have South migrations enabled for testing, even though they it's not too efficient
+# def _fixture_setup(self):
+# # HACK: Create askbot_post database VIEW for the purpose of performing tests
+# import os.path
+# from django.conf import settings
+# from django.db import connection
+# sql = open(os.path.join(settings.PROJECT_ROOT, 'askbot', 'models', 'post_view.sql'), 'rt').read()
+# cursor = connection.cursor()
+# import warnings
+# warnings.filterwarnings("ignore", "Unknown table .*?\.askbot_post'") # DROP VIEW might raise a warning so let's filter that out
+# cursor.execute('DROP VIEW IF EXISTS askbot_post')
+# cursor.execute(sql)
+## connection.connection.store_result()
+# connection.close()
+# super(AskbotTestCase, self)._fixture_setup()
+#
+# def _fixture_teardown(self):
+# super(AskbotTestCase, self)._fixture_teardown()
+# from django.db import connection
+# cursor = connection.cursor()
+# cursor.execute('DROP VIEW IF EXISTS askbot_post')
+# connection.close()
def create_user(