Avoid killing the test database teardown.

Inserting a MB into the test database kills the _fixture_teardown method when it tries to roll back transactions.
This commit is contained in:
Ray Schamp 2014-12-30 11:34:58 -05:00
parent 56fe401721
commit ec9568d6ba
2 changed files with 7 additions and 3 deletions
djangobb_forum

View file

@ -588,6 +588,8 @@ class PostStatus(models.Model):
MARKED_SPAM = 'marked_spam'
MARKED_HAM = 'marked_ham'
AKISMET_MAX_SIZE = 1024*500
post = models.OneToOneField(Post, db_index=True)
state = FSMField(default=UNREVIEWED, db_index=True)
topic = models.ForeignKey(Topic) # Original topic
@ -681,7 +683,7 @@ class PostStatus(models.Model):
Truncate the post body to the largest allowed string size. Use size, not
length, since the Akismet server checks size, not length.
"""
return self.post.body.encode('utf-8')[:1024*500].decode('utf-8', 'ignore')
return self.post.body.encode('utf-8')[:self.AKISMET_MAX_SIZE].decode('utf-8', 'ignore')
def _comment_check(self):
"""

View file

@ -154,13 +154,15 @@ class ForumSpamTests(TestCase):
def test_content_truncated(self):
"""
Content larger than 0.5MB shouldn't be sent up to Akismet, which rejects
anything too big.
anything too big. For the test, we reduce the cap, since the test
database seems to have issues tearing down when that much data is present.
"""
huge_content = ":lol:"*1024*1024
huge_content = ":lol:"*1024
huge_post = Post.objects.create(
topic=self.test_topic, user=self.user, body=huge_content,
body_html="<p>%s</p>"%huge_content)
huge_post_status = PostStatus.objects.create_for_post(huge_post)
huge_post_status.AKISMET_MAX_SIZE = 512
self.assertGreater(len(huge_content), len(huge_post_status.to_akismet_content()))
def test_content_untruncated(self):