move AtpNode to arroba

pull/602/head
Ryan Barrett 2023-07-26 08:22:34 -07:00
rodzic 9332506be6
commit b57c96d7d5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 1 dodań i 41 usunięć

Wyświetl plik

@ -610,38 +610,6 @@ class Object(StringIdModel):
</a>"""
class AtpNode(StringIdModel):
"""An AT Protocol (Bluesky) node.
May be a data record, an MST node, or a commit.
Key name is the DAG-CBOR base32 CID of the data.
Properties:
* data: JSON-decoded DAG-JSON value of this node
* obj: optional, Key of the corresponding :class:`Object`, only populated
for records
"""
data = JsonProperty(required=True)
obj = ndb.KeyProperty(Object)
@staticmethod
def create(data):
"""Writes a new AtpNode to the datastore.
Args:
data: dict value
Returns:
:class:`AtpNode`
"""
data = json.loads(dag_json.encode(data))
cid = dag_cbor_cid(data)
node = AtpNode(id=cid.encode('base32'), data=data)
node.put()
return node
class Follower(ndb.Model):
"""A follower of a Bridgy Fed user."""
STATUSES = ('active', 'inactive')

Wyświetl plik

@ -10,7 +10,7 @@ from oauth_dropins.webutil.testutil import NOW
# import first so that Fake is defined before URL routes are registered
from .testutil import Fake, TestCase
from models import AtpNode, Follower, Object, OBJECT_EXPIRE_AGE, Target, User
from models import Follower, Object, OBJECT_EXPIRE_AGE, Target, User
import protocol
from protocol import Protocol
from web import Web
@ -447,11 +447,3 @@ class FollowerTest(TestCase):
status='inactive')
got = follower.key.get()
self.assertEqual('inactive', got.status)
class AtpNodeTest(TestCase):
def test_create(self):
AtpNode.create(ACTOR_PROFILE_BSKY)
stored = AtpNode.get_by_id(dag_cbor_cid(ACTOR_PROFILE_BSKY).encode('base32'))
self.assertEqual(ACTOR_PROFILE_BSKY, stored.data)