mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-01 21:08:42 +00:00
fixes inconsistency in to_undo activity helper
This commit is contained in:
parent
39307ce1cd
commit
800ddf2a6b
2 changed files with 20 additions and 3 deletions
|
@ -142,10 +142,10 @@ class ActivitypubMixin:
|
||||||
def to_undo_activity(self, user):
|
def to_undo_activity(self, user):
|
||||||
''' undo an action '''
|
''' undo an action '''
|
||||||
return activitypub.Undo(
|
return activitypub.Undo(
|
||||||
id='%s#undo' % user.remote_id,
|
id='%s#undo' % self.remote_id,
|
||||||
actor=user.remote_id,
|
actor=user.remote_id,
|
||||||
object=self.to_activity()
|
object=self.to_activity()
|
||||||
)
|
).serialize()
|
||||||
|
|
||||||
|
|
||||||
class OrderedCollectionPageMixin(ActivitypubMixin):
|
class OrderedCollectionPageMixin(ActivitypubMixin):
|
||||||
|
|
|
@ -105,7 +105,6 @@ class BaseModel(TestCase):
|
||||||
lambda *args: {}
|
lambda *args: {}
|
||||||
)
|
)
|
||||||
activity = ActivitypubMixin.to_update_activity(mock_self, user)
|
activity = ActivitypubMixin.to_update_activity(mock_self, user)
|
||||||
print(activity['id'])
|
|
||||||
self.assertIsNotNone(
|
self.assertIsNotNone(
|
||||||
re.match(
|
re.match(
|
||||||
r'^https:\/\/example\.com\/status\/1#update\/.*',
|
r'^https:\/\/example\.com\/status\/1#update\/.*',
|
||||||
|
@ -118,3 +117,21 @@ class BaseModel(TestCase):
|
||||||
activity['to'],
|
activity['to'],
|
||||||
['https://www.w3.org/ns/activitystreams#Public'])
|
['https://www.w3.org/ns/activitystreams#Public'])
|
||||||
self.assertEqual(activity['object'], {})
|
self.assertEqual(activity['object'], {})
|
||||||
|
|
||||||
|
def test_to_undo_activity(self):
|
||||||
|
user = models.User.objects.create_user(
|
||||||
|
'mouse', 'mouse@mouse.com', 'mouseword', local=True)
|
||||||
|
|
||||||
|
MockSelf = namedtuple('Self', ('remote_id', 'to_activity'))
|
||||||
|
mock_self = MockSelf(
|
||||||
|
'https://example.com/status/1',
|
||||||
|
lambda *args: {}
|
||||||
|
)
|
||||||
|
activity = ActivitypubMixin.to_undo_activity(mock_self, user)
|
||||||
|
self.assertEqual(
|
||||||
|
activity['id'],
|
||||||
|
'https://example.com/status/1#undo'
|
||||||
|
)
|
||||||
|
self.assertEqual(activity['actor'], user.remote_id)
|
||||||
|
self.assertEqual(activity['type'], 'Undo')
|
||||||
|
self.assertEqual(activity['object'], {})
|
||||||
|
|
Loading…
Reference in a new issue