kopia lustrzana https://github.com/snarfed/bridgy-fed
bug fix for ids.web_ap_base_domain
...and test it properly instead of mocking out the constantpull/968/head
rodzic
34692abc60
commit
c87e69d354
2
ids.py
2
ids.py
|
@ -52,7 +52,7 @@ def web_ap_base_domain(user_domain):
|
|||
if _NON_WEB_SUBDOMAIN_SITES is None:
|
||||
_NON_WEB_SUBDOMAIN_SITES = {
|
||||
user.key.id(): user.ap_subdomain
|
||||
for key in Query('MagicKey',
|
||||
for user in Query('MagicKey',
|
||||
filters=FilterNode('ap_subdomain', '!=', 'web'),
|
||||
projection=['ap_subdomain'],
|
||||
).fetch()
|
||||
|
|
|
@ -88,11 +88,10 @@ class IdsTest(TestCase):
|
|||
self.assertEqual(expected, translate_user_id(
|
||||
id='https://www.user.com/', from_=Web, to=proto))
|
||||
|
||||
@patch('ids._NON_WEB_SUBDOMAIN_SITES', new={
|
||||
'on-bsky.com': 'bsky',
|
||||
'on-fed.com': 'fed',
|
||||
})
|
||||
def test_translate_user_id_web_ap_subdomain_fed(self):
|
||||
self.make_user('on-fed.com', cls=Web, ap_subdomain='fed')
|
||||
self.make_user('on-bsky.com', cls=Web, ap_subdomain='bsky')
|
||||
|
||||
for base_url in ['https://web.brid.gy/', 'https://fed.brid.gy/']:
|
||||
with app.test_request_context('/', base_url=base_url):
|
||||
self.assertEqual('https://web.brid.gy/on-web.com', translate_user_id(
|
||||
|
@ -198,8 +197,9 @@ class IdsTest(TestCase):
|
|||
self.assertEqual(expected, translate_object_id(
|
||||
id=id, from_=from_, to=to))
|
||||
|
||||
@patch('ids._NON_WEB_SUBDOMAIN_SITES', new={'on-fed.com': 'fed'})
|
||||
def test_translate_object_id_web_ap_subdomain_fed(self):
|
||||
self.make_user('on-fed.com', cls=Web, ap_subdomain='fed')
|
||||
|
||||
for base_url in ['https://web.brid.gy/', 'https://fed.brid.gy/']:
|
||||
with app.test_request_context('/', base_url=base_url):
|
||||
got = translate_object_id(id='http://on-fed.com/post', from_=Web,
|
||||
|
|
|
@ -230,6 +230,7 @@ class TestCase(unittest.TestCase, testutil.Asserts):
|
|||
cls.fetched = []
|
||||
cls.created_for = []
|
||||
|
||||
ids._NON_WEB_SUBDOMAIN_SITES = None
|
||||
ids.COPIES_PROTOCOLS = ('atproto', 'fake', 'other')
|
||||
common.PROTOCOL_DOMAINS = (
|
||||
'ap.brid.gy',
|
||||
|
|
Ładowanie…
Reference in New Issue