From 9e2447dd57a9f9a958b0e02718f72bbb90f63a00 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Mon, 20 May 2024 11:25:35 -0700 Subject: [PATCH] ATProto.convert: test guessing mention facet indices when displayName has full @-@ with server for #957 --- tests/test_atproto.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/test_atproto.py b/tests/test_atproto.py index cae9f42..167d8d5 100644 --- a/tests/test_atproto.py +++ b/tests/test_atproto.py @@ -646,6 +646,39 @@ class ATProtoTest(TestCase): }], }))) + # resolveHandle + @patch('requests.get', return_value=requests_response({'did': 'did:plc:user'})) + def test_convert_resolve_mention_handle_drop_server(self, mock_get): + self.store_object(id='did:plc:user', raw=DID_DOC) + + self.assertEqual({ + '$type': 'app.bsky.feed.post', + 'createdAt': '2022-01-02T03:04:05.000Z', + 'text': 'hi @han.dull hows it going', + 'facets': [{ + '$type': 'app.bsky.richtext.facet', + 'features': [{ + '$type': 'app.bsky.richtext.facet#mention', + 'did': 'did:plc:user', + }], + 'index': { + 'byteEnd': 12, + 'byteStart': 3, + }, + }], + }, ATProto.convert(Object(our_as1={ + 'objectType': 'comment', + 'content': 'hi @han.dull hows it going', + 'tags': [{ + 'objectType': 'mention', + 'url': 'did:plc:user', + # we should find the mentioned handle in the content text even + # if it doesn't have @ser.ver + # https://github.com/snarfed/bridgy-fed/issues/957 + 'displayName': '@han.dull@ser.ver' + }], + }))) + def test_convert_actor_from_atproto_doesnt_add_self_label(self): self.assertEqual({ '$type': 'app.bsky.actor.profile',