From 5a1dda151c10f4d4755111fed007ca80d30f1b42 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Wed, 20 Mar 2024 14:16:39 -0700 Subject: [PATCH] ATProto.create_for: better support for local testing --- atproto.py | 9 ++++++--- models.py | 2 +- tests/test_atproto.py | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/atproto.py b/atproto.py index 035de77..f6c1c13 100644 --- a/atproto.py +++ b/atproto.py @@ -208,9 +208,10 @@ class ATProto(User, Protocol): return # create new DID, repo - logger.info(f'Creating new did:plc for {user.key}') + pds_url = common.host_url() if DEBUG else cls.PDS_URL + logger.info(f'Creating new did:plc for {user.key} {pds_url}') did_plc = did.create_plc(user.handle_as('atproto'), - pds_url=cls.PDS_URL, + pds_url=pds_url, post_fn=util.requests_post) Object.get_or_create(did_plc.did, raw=did_plc.doc) @@ -223,7 +224,9 @@ class ATProto(User, Protocol): name = f'_atproto.{handle}.' val = f'"did={did_plc.did}"' logger.info(f'adding GCP DNS TXT record for {name} {val}') - if not DEBUG: + if DEBUG: + logger.info(' skipped since DEBUG is true') + else: zone = dns_client.zone(DNS_ZONE) r = zone.resource_record_set(name=name, record_type='TXT', ttl=DNS_TTL, rrdatas=[val]) diff --git a/models.py b/models.py index ea7dc9b..086ff4c 100644 --- a/models.py +++ b/models.py @@ -37,7 +37,7 @@ PROTOCOLS = {'ostatus': None} # 2048 bits makes tests slow, so use 1024 for them KEY_BITS = 1024 if DEBUG else 2048 -PAGE_SIZE = 20 +PAGE_SIZE = 30 # auto delete old objects of these types via the Object.expire property # https://cloud.google.com/datastore/docs/ttl diff --git a/tests/test_atproto.py b/tests/test_atproto.py index 02e1f04..33e553b 100644 --- a/tests/test_atproto.py +++ b/tests/test_atproto.py @@ -644,7 +644,7 @@ class ATProtoTest(TestCase): assert did self.assertEqual([Target(uri=did, protocol='atproto')], user.copies) did_obj = ATProto.load(did, did_doc=True) - self.assertEqual('https://atproto.brid.gy/', + self.assertEqual('http://localhost/', did_obj.raw['service'][0]['serviceEndpoint']) # check repo, record @@ -678,7 +678,7 @@ class ATProtoTest(TestCase): 'services': { 'atproto_pds': { 'type': 'AtprotoPersonalDataServer', - 'endpoint': 'https://atproto.brid.gy/', + 'endpoint': 'http://localhost/', } }, 'prev': None,