mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 16:40:36 +00:00
Add Quotation endposition test
This commit is contained in:
parent
f085315d70
commit
f65e0b7632
2 changed files with 44 additions and 8 deletions
|
@ -8,19 +8,28 @@ import django.db.models.deletion
|
|||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('auth', '0012_alter_user_first_name_max_length'),
|
||||
('bookwyrm', '0173_default_user_auth_group_setting'),
|
||||
("auth", "0012_alter_user_first_name_max_length"),
|
||||
("bookwyrm", "0173_default_user_auth_group_setting"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='quotation',
|
||||
name='endposition',
|
||||
field=models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0)]),
|
||||
model_name="quotation",
|
||||
name="endposition",
|
||||
field=models.IntegerField(
|
||||
blank=True,
|
||||
null=True,
|
||||
validators=[django.core.validators.MinValueValidator(0)],
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='sitesettings',
|
||||
name='default_user_auth_group',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='auth.group'),
|
||||
model_name="sitesettings",
|
||||
name="default_user_auth_group",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
to="auth.group",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -257,6 +257,33 @@ class BookViews(TestCase):
|
|||
self.assertEqual(mock.call_args[0][0], "https://openlibrary.org/book/123")
|
||||
self.assertEqual(result.status_code, 302)
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
def test_quotation_endposition(self, *_):
|
||||
"""make sure the endposition is served as well"""
|
||||
view = views.Book.as_view()
|
||||
|
||||
quote = models.Quotation.objects.create(
|
||||
user=self.local_user,
|
||||
book=self.book,
|
||||
content="hi",
|
||||
quote="wow",
|
||||
position=12,
|
||||
endposition=13,
|
||||
)
|
||||
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
|
||||
with patch("bookwyrm.views.books.books.is_api_request") as is_api:
|
||||
is_api.return_value = False
|
||||
result = view(request, self.book.id, user_statuses="quotation")
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
validate_html(result.render())
|
||||
print(result.render())
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(result.context_data["statuses"].object_list[0].endposition, 13)
|
||||
|
||||
|
||||
def _setup_cover_url():
|
||||
"""creates cover url mock"""
|
||||
|
|
Loading…
Reference in a new issue