Double speed of Python tests by removing fixtures code.

(We don't need the fixtures code once we override Django's
run_suite() method not to clobber our test database, since
all our tests use the same data anyway, and since Django
runs all the tests in a transaction and rolls back their
changes.)

(imported from commit d9daf09be3967de2de30934173b882d3d6b9ea27)
This commit is contained in:
Steve Howell
2013-06-19 16:45:05 -04:00
parent 3c79f6fa53
commit 07afbabb79

View File

@@ -194,7 +194,6 @@ class PublicURLTest(TestCase):
Account creation URLs are accessible even when not logged in. Authenticated Account creation URLs are accessible even when not logged in. Authenticated
URLs redirect to a page. URLs redirect to a page.
""" """
fixtures = ['messages.json']
def fetch(self, method, urls, expected_status): def fetch(self, method, urls, expected_status):
for url in urls: for url in urls:
@@ -254,7 +253,6 @@ class LoginTest(AuthedTestCase):
""" """
Logging in, registration, and logging out. Logging in, registration, and logging out.
""" """
fixtures = ['messages.json']
def test_login(self): def test_login(self):
self.login("hamlet@humbughq.com") self.login("hamlet@humbughq.com")
@@ -295,7 +293,6 @@ class LoginTest(AuthedTestCase):
self.assertEqual(self.client.session['_auth_user_id'], user_profile.id) self.assertEqual(self.client.session['_auth_user_id'], user_profile.id)
class PersonalMessagesTest(AuthedTestCase): class PersonalMessagesTest(AuthedTestCase):
fixtures = ['messages.json']
def test_auto_subbed_to_personals(self): def test_auto_subbed_to_personals(self):
""" """
@@ -387,7 +384,6 @@ class PersonalMessagesTest(AuthedTestCase):
self.assert_personal("hamlet@humbughq.com", "othello@humbughq.com", u"hümbüǵ") self.assert_personal("hamlet@humbughq.com", "othello@humbughq.com", u"hümbüǵ")
class StreamMessagesTest(AuthedTestCase): class StreamMessagesTest(AuthedTestCase):
fixtures = ['messages.json']
def assert_stream_message(self, stream_name, subject="test subject", def assert_stream_message(self, stream_name, subject="test subject",
content="test content"): content="test content"):
@@ -448,7 +444,6 @@ class StreamMessagesTest(AuthedTestCase):
content=u"hümbüǵ") content=u"hümbüǵ")
class PointerTest(AuthedTestCase): class PointerTest(AuthedTestCase):
fixtures = ['messages.json']
def test_update_pointer(self): def test_update_pointer(self):
""" """
@@ -508,7 +503,6 @@ class PointerTest(AuthedTestCase):
self.assertEqual(self.get_user_profile("hamlet@humbughq.com").pointer, -1) self.assertEqual(self.get_user_profile("hamlet@humbughq.com").pointer, -1)
class MessagePOSTTest(AuthedTestCase): class MessagePOSTTest(AuthedTestCase):
fixtures = ['messages.json']
def test_message_to_self(self): def test_message_to_self(self):
""" """
@@ -610,7 +604,6 @@ class MessagePOSTTest(AuthedTestCase):
self.assert_json_success(result) self.assert_json_success(result)
class SubscriptionPropertiesTest(AuthedTestCase): class SubscriptionPropertiesTest(AuthedTestCase):
fixtures = ['messages.json']
def test_get_stream_color(self): def test_get_stream_color(self):
""" """
@@ -706,7 +699,6 @@ class SubscriptionPropertiesTest(AuthedTestCase):
"Unknown subscription property: bad") "Unknown subscription property: bad")
class SubscriptionAPITest(AuthedTestCase): class SubscriptionAPITest(AuthedTestCase):
fixtures = ['messages.json']
def setUp(self): def setUp(self):
""" """
@@ -1033,7 +1025,6 @@ class SubscriptionAPITest(AuthedTestCase):
self.assert_json_error(result, "Invalid characters in stream name") self.assert_json_error(result, "Invalid characters in stream name")
class GetOldMessagesTest(AuthedTestCase): class GetOldMessagesTest(AuthedTestCase):
fixtures = ['messages.json']
def post_with_params(self, modified_params): def post_with_params(self, modified_params):
post_params = {"anchor": 1, "num_before": 1, "num_after": 1} post_params = {"anchor": 1, "num_before": 1, "num_after": 1}
@@ -1253,7 +1244,6 @@ class GetOldMessagesTest(AuthedTestCase):
"Invalid narrow operator: unknown user") "Invalid narrow operator: unknown user")
class InviteUserTest(AuthedTestCase): class InviteUserTest(AuthedTestCase):
fixtures = ['messages.json']
def invite(self, users, streams): def invite(self, users, streams):
""" """
@@ -1407,7 +1397,6 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
self.assert_json_success(self.invite(invitee, [stream_name])) self.assert_json_success(self.invite(invitee, [stream_name]))
class ChangeSettingsTest(AuthedTestCase): class ChangeSettingsTest(AuthedTestCase):
fixtures = ['messages.json']
def post_with_params(self, modified_params): def post_with_params(self, modified_params):
post_params = {"full_name": "Foo Bar", post_params = {"full_name": "Foo Bar",
@@ -1479,7 +1468,6 @@ class ChangeSettingsTest(AuthedTestCase):
self.assert_json_error(result, "Wrong password!") self.assert_json_error(result, "Wrong password!")
class S3Test(AuthedTestCase): class S3Test(AuthedTestCase):
fixtures = ['messages.json']
test_uris = [] test_uris = []
def test_file_upload(self): def test_file_upload(self):
@@ -1561,7 +1549,6 @@ class POSTRequestMock(object):
self.META = {'PATH_INFO': 'test'} self.META = {'PATH_INFO': 'test'}
class GetUpdatesTest(AuthedTestCase): class GetUpdatesTest(AuthedTestCase):
fixtures = ['messages.json']
def common_test_get_updates(self, view_func, extra_post_data = {}): def common_test_get_updates(self, view_func, extra_post_data = {}):
user_profile = self.get_user_profile("hamlet@humbughq.com") user_profile = self.get_user_profile("hamlet@humbughq.com")
@@ -1615,7 +1602,6 @@ class GetUpdatesTest(AuthedTestCase):
self.assertRaises(RequestVariableConversionError, json_get_updates, request) self.assertRaises(RequestVariableConversionError, json_get_updates, request)
class GetProfileTest(AuthedTestCase): class GetProfileTest(AuthedTestCase):
fixtures = ['messages.json']
def common_update_pointer(self, email, pointer): def common_update_pointer(self, email, pointer):
self.login(email) self.login(email)
@@ -1665,7 +1651,6 @@ class GetProfileTest(AuthedTestCase):
self.assertEqual(json["pointer"], 1) self.assertEqual(json["pointer"], 1)
class GetPublicStreamsTest(AuthedTestCase): class GetPublicStreamsTest(AuthedTestCase):
fixtures = ['messages.json']
def test_public_streams(self): def test_public_streams(self):
""" """
@@ -1684,7 +1669,6 @@ class GetPublicStreamsTest(AuthedTestCase):
self.assertIsInstance(json["streams"], list) self.assertIsInstance(json["streams"], list)
class InviteOnlyStreamTest(AuthedTestCase): class InviteOnlyStreamTest(AuthedTestCase):
fixtures = ['messages.json']
def common_subscribe_to_stream(self, email, streams, extra_post_data = {}, invite_only=False): def common_subscribe_to_stream(self, email, streams, extra_post_data = {}, invite_only=False):
api_key = self.get_api_key(email) api_key = self.get_api_key(email)
@@ -1758,7 +1742,6 @@ class InviteOnlyStreamTest(AuthedTestCase):
self.assertTrue('hamlet@humbughq.com' in json['subscribers']) self.assertTrue('hamlet@humbughq.com' in json['subscribers'])
class GetSubscribersTest(AuthedTestCase): class GetSubscribersTest(AuthedTestCase):
fixtures = ['messages.json']
def setUp(self): def setUp(self):
self.email = "hamlet@humbughq.com" self.email = "hamlet@humbughq.com"
@@ -2324,7 +2307,6 @@ But you can never leave**"""
self.assertEqual(converted, '<p>We should fix <a href="https://trac.humbughq.com/ticket/224" target="_blank" title="https://trac.humbughq.com/ticket/224">trac #224</a> and <a href="https://trac.humbughq.com/ticket/115" target="_blank" title="https://trac.humbughq.com/ticket/115">Trac #115</a>, but not Ztrac #124 or trac #1124Z today.</p>') self.assertEqual(converted, '<p>We should fix <a href="https://trac.humbughq.com/ticket/224" target="_blank" title="https://trac.humbughq.com/ticket/224">trac #224</a> and <a href="https://trac.humbughq.com/ticket/115" target="_blank" title="https://trac.humbughq.com/ticket/115">Trac #115</a>, but not Ztrac #124 or trac #1124Z today.</p>')
class UserPresenceTests(AuthedTestCase): class UserPresenceTests(AuthedTestCase):
fixtures = ['messages.json']
def common_init(self, email): def common_init(self, email):
self.login(email) self.login(email)
@@ -2432,7 +2414,6 @@ class UserPresenceTests(AuthedTestCase):
self.assertEqual(email.split('@')[1], 'humbughq.com') self.assertEqual(email.split('@')[1], 'humbughq.com')
class UnreadCountTests(AuthedTestCase): class UnreadCountTests(AuthedTestCase):
fixtures = ['messages.json']
def test_initial_counts(self): def test_initial_counts(self):
# All test users have a pointer at -1, so all messages are read # All test users have a pointer at -1, so all messages are read
@@ -2506,7 +2487,6 @@ class UnreadCountTests(AuthedTestCase):
self.assertEqual(msg['flags'], []) self.assertEqual(msg['flags'], [])
class StarTests(AuthedTestCase): class StarTests(AuthedTestCase):
fixtures = ['messages.json']
def change_star(self, messages, add=True): def change_star(self, messages, add=True):
return self.client.post("/json/update_message_flags", return self.client.post("/json/update_message_flags",
@@ -2557,7 +2537,6 @@ class StarTests(AuthedTestCase):
self.assertFalse(sent_message.flags.starred) self.assertFalse(sent_message.flags.starred)
class JiraHookTests(AuthedTestCase): class JiraHookTests(AuthedTestCase):
fixtures = ['messages.json']
def send_jira_message(self, action): def send_jira_message(self, action):
email = "hamlet@humbughq.com" email = "hamlet@humbughq.com"
@@ -2667,7 +2646,6 @@ class JiraHookTests(AuthedTestCase):
self.assertEqual(msg.content, """Leo Franchi [Administrator] **transitioned** [TEST-7](https://lfranchi-test.atlassian.net/browse/TEST-7) from Open to Resolved""") self.assertEqual(msg.content, """Leo Franchi [Administrator] **transitioned** [TEST-7](https://lfranchi-test.atlassian.net/browse/TEST-7) from Open to Resolved""")
class BeanstalkHookTests(AuthedTestCase): class BeanstalkHookTests(AuthedTestCase):
fixtures = ['messages.json']
def http_auth(self, username, password): def http_auth(self, username, password):
import base64 import base64
@@ -2717,7 +2695,6 @@ class BeanstalkHookTests(AuthedTestCase):
> Added some code""") > Added some code""")
class GithubHookTests(AuthedTestCase): class GithubHookTests(AuthedTestCase):
fixtures = ['messages.json']
def assert_content(self, msg): def assert_content(self, msg):
self.assertEqual(msg.content, """rtomayko [pushed](http://github.com/mojombo/grit/compare/4c8124f...a47fd41) to branch master self.assertEqual(msg.content, """rtomayko [pushed](http://github.com/mojombo/grit/compare/4c8124f...a47fd41) to branch master
@@ -2800,7 +2777,6 @@ class GithubHookTests(AuthedTestCase):
self.assert_content(msg) self.assert_content(msg)
class PivotalHookTests(AuthedTestCase): class PivotalHookTests(AuthedTestCase):
fixtures = ['messages.json']
def send_pivotal_message(self, name): def send_pivotal_message(self, name):
email = "hamlet@humbughq.com" email = "hamlet@humbughq.com"
@@ -2873,7 +2849,6 @@ class PivotalHookTests(AuthedTestCase):
[(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573)') [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573)')
class RateLimitTests(AuthedTestCase): class RateLimitTests(AuthedTestCase):
fixtures = ['messages.json']
def setUp(self): def setUp(self):
settings.RATE_LIMITING = True settings.RATE_LIMITING = True