kopia lustrzana https://github.com/snarfed/bridgy-fed
move AtpNode to arroba
rodzic
9332506be6
commit
b57c96d7d5
32
models.py
32
models.py
|
@ -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')
|
||||
|
|
|
@ -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)
|
||||
|
|
Ładowanie…
Reference in New Issue