ATProto.convert: test guessing mention facet indices when displayName has full @-@ with server

for #957
pull/1067/head
Ryan Barrett 2024-05-20 11:25:35 -07:00
rodzic edf3b5894e
commit 9e2447dd57
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
1 zmienionych plików z 33 dodań i 0 usunięć

Wyświetl plik

@ -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 <a href="https://bsky.brid.gy/ap/did:plc:user">@<span>han.dull</span></a> 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',