bug fix for ids.web_ap_base_domain

...and test it properly instead of mocking out the constant
pull/968/head
Ryan Barrett 2024-04-22 15:15:27 -07:00
rodzic 34692abc60
commit c87e69d354
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
3 zmienionych plików z 10 dodań i 9 usunięć

8
ids.py
Wyświetl plik

@ -52,10 +52,10 @@ 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',
filters=FilterNode('ap_subdomain', '!=', 'web'),
projection=['ap_subdomain'],
).fetch()
for user in Query('MagicKey',
filters=FilterNode('ap_subdomain', '!=', 'web'),
projection=['ap_subdomain'],
).fetch()
}
logger.info(f'Loaded {len(_NON_WEB_SUBDOMAIN_SITES)} non-web.brid.gy Web users')

Wyświetl plik

@ -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,

Wyświetl plik

@ -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',