Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelOtter authored and snarfed committed Feb 4, 2024
1 parent 038703b commit 701f7bb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions granary/tests/test_bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@
'record': REPLY_BSKY,
})

# Replies to non-Bluesky posts, but which are syndicated to Bluesky.
# The object will have several inReplyTo URLs - Granary should pick the
# correct one.
REPLY_TO_WEBSITE_AS = copy.deepcopy(REPLY_AS)
REPLY_TO_WEBSITE_AS['object']['inReplyTo'] = [
{'url': 'http://example.com/post'},
{'url': 'https://mastodon.social/@alice/post'},
{'url': 'https://bsky.app/profile/did:alice/post/parent-tid'},
]

REPOST_AS = {
'objectType': 'activity',
'verb': 'share',
Expand Down Expand Up @@ -835,6 +845,13 @@ def test_from_as1_reply(self):
self.assert_equals(REPLY_BSKY, from_as1(REPLY_AS))
self.assert_equals(REPLY_BSKY, from_as1(REPLY_AS['object']))

def test_from_as1_reply_to_website(self):
self.assert_equals(REPLY_BSKY, from_as1(REPLY_TO_WEBSITE_AS))
self.assert_equals(REPLY_BSKY, from_as1(REPLY_TO_WEBSITE_AS['object']))
reply_to_website_at_uri = copy.deepcopy(REPLY_TO_WEBSITE_AS)
reply_to_website_at_uri['object']['inReplyTo'][2]['url'] = 'at://did:alice/app.bsky.feed.post/parent-tid'
self.assert_equals(REPLY_BSKY, from_as1(reply_to_website_at_uri))

def test_from_as1_reply_postView(self):
for input in REPLY_AS, REPLY_AS['object']:
got = from_as1(input, out_type='app.bsky.feed.defs#postView')
Expand Down

0 comments on commit 701f7bb

Please sign in to comment.