Adds preview mock to postgres tests

This commit is contained in:
Mouse Reeve 2021-06-26 18:36:17 -07:00
parent 36fe64c3ae
commit a3badc5700

View file

@ -6,16 +6,18 @@ from bookwyrm import models
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay") @patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
@patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay")
class PostgresTriggers(TestCase): class PostgresTriggers(TestCase):
"""special migrations, fancy stuff ya know""" """special migrations, fancy stuff ya know"""
def test_search_vector_on_create(self, _): def test_search_vector_on_create(self, *_):
"""make sure that search_vector is being set correctly on create""" """make sure that search_vector is being set correctly on create"""
print('hello?')
book = models.Edition.objects.create(title="The Long Goodbye") book = models.Edition.objects.create(title="The Long Goodbye")
book.refresh_from_db() book.refresh_from_db()
self.assertEqual(book.search_vector, "'goodby':3A 'long':2A") self.assertEqual(book.search_vector, "'goodby':3A 'long':2A")
def test_search_vector_on_update(self, _): def test_search_vector_on_update(self, *_):
"""make sure that search_vector is being set correctly on edit""" """make sure that search_vector is being set correctly on edit"""
book = models.Edition.objects.create(title="The Long Goodbye") book = models.Edition.objects.create(title="The Long Goodbye")
book.title = "The Even Longer Goodbye" book.title = "The Even Longer Goodbye"
@ -23,7 +25,7 @@ class PostgresTriggers(TestCase):
book.refresh_from_db() book.refresh_from_db()
self.assertEqual(book.search_vector, "'even':2A 'goodby':4A 'longer':3A") self.assertEqual(book.search_vector, "'even':2A 'goodby':4A 'longer':3A")
def test_search_vector_fields(self, _): def test_search_vector_fields(self, *_):
"""use multiple fields to create search vector""" """use multiple fields to create search vector"""
author = models.Author.objects.create(name="The Rays") author = models.Author.objects.create(name="The Rays")
book = models.Edition.objects.create( book = models.Edition.objects.create(
@ -39,7 +41,7 @@ class PostgresTriggers(TestCase):
"'cool':5B 'goodby':3A 'long':2A 'name':9 'rays':7B 'seri':8 'the':6B 'wow':4B", "'cool':5B 'goodby':3A 'long':2A 'name':9 'rays':7B 'seri':8 'the':6B 'wow':4B",
) )
def test_seach_vector_on_author_update(self, _): def test_seach_vector_on_author_update(self, *_):
"""update search when an author name changes""" """update search when an author name changes"""
author = models.Author.objects.create(name="The Rays") author = models.Author.objects.create(name="The Rays")
book = models.Edition.objects.create( book = models.Edition.objects.create(
@ -52,7 +54,7 @@ class PostgresTriggers(TestCase):
self.assertEqual(book.search_vector, "'goodby':3A 'jeremy':4B 'long':2A") self.assertEqual(book.search_vector, "'goodby':3A 'jeremy':4B 'long':2A")
def test_seach_vector_on_author_delete(self, _): def test_seach_vector_on_author_delete(self, *_):
"""update search when an author name changes""" """update search when an author name changes"""
author = models.Author.objects.create(name="Jeremy") author = models.Author.objects.create(name="Jeremy")
book = models.Edition.objects.create( book = models.Edition.objects.create(
@ -67,7 +69,7 @@ class PostgresTriggers(TestCase):
book.refresh_from_db() book.refresh_from_db()
self.assertEqual(book.search_vector, "'goodby':3A 'long':2A") self.assertEqual(book.search_vector, "'goodby':3A 'long':2A")
def test_search_vector_stop_word_fallback(self, _): def test_search_vector_stop_word_fallback(self, *_):
"""use a fallback when removing stop words leads to an empty vector""" """use a fallback when removing stop words leads to an empty vector"""
book = models.Edition.objects.create( book = models.Edition.objects.create(
title="there there", title="there there",