aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyapd/ctl.py2
-rw-r--r--pyapd/objects.py2
-rw-r--r--pyapd/stores/memory.py4
-rw-r--r--pyapd/stores/sqlite.py4
-rw-r--r--tests/test_app.py2
-rw-r--r--tests/test_memory_store.py4
-rw-r--r--tests/test_objects.py8
-rw-r--r--tests/test_sqlite_store.py4
8 files changed, 15 insertions, 15 deletions
diff --git a/pyapd/ctl.py b/pyapd/ctl.py
index 1355d1c..e068379 100644
--- a/pyapd/ctl.py
+++ b/pyapd/ctl.py
@@ -18,7 +18,7 @@ class Commands():
return "pong"
def add_object(self, obj: dict):
- new_obj = objects.Object(**obj)
+ new_obj = objects.APObject(**obj)
self.srv.app.store.add(new_obj)
return "ok"
diff --git a/pyapd/objects.py b/pyapd/objects.py
index c8bbbb0..13284ee 100644
--- a/pyapd/objects.py
+++ b/pyapd/objects.py
@@ -3,7 +3,7 @@ import json
@dataclasses.dataclass
-class Object:
+class APObject:
# TODO: assign the correct type
ap_id: str = ''
ap_type: str = ''
diff --git a/pyapd/stores/memory.py b/pyapd/stores/memory.py
index e81b5cf..b2aa73d 100644
--- a/pyapd/stores/memory.py
+++ b/pyapd/stores/memory.py
@@ -6,10 +6,10 @@ class Store():
def __init__(self):
self.objects = {}
- def add(self, obj: objects.Object):
+ def add(self, obj: objects.APObject):
self.objects[obj.ap_id] = obj
- def get(self, oid: str) -> objects.Object:
+ def get(self, oid: str) -> objects.APObject:
try:
return self.objects[oid]
except KeyError:
diff --git a/pyapd/stores/sqlite.py b/pyapd/stores/sqlite.py
index 641600f..fc81ac2 100644
--- a/pyapd/stores/sqlite.py
+++ b/pyapd/stores/sqlite.py
@@ -11,7 +11,7 @@ class Store():
file = ':memory:'
self.db = sqlite3.connect(file)
- def add(self, obj: objects.Object):
+ def add(self, obj: objects.APObject):
obj_type = type(obj).__name__.lower()
c = self.db.cursor()
c.execute('''insert or replace
@@ -27,7 +27,7 @@ class Store():
# self.objects[obj_type] = {}
# self.objects[obj_type][obj.ap_id] = obj
- def get(self, obj_type: str, oid: str) -> objects.Object:
+ def get(self, obj_type: str, oid: str) -> objects.APObject:
c = self.db.cursor()
c.execute(
'select obj from objects'
diff --git a/tests/test_app.py b/tests/test_app.py
index 1f9116b..e8acb01 100644
--- a/tests/test_app.py
+++ b/tests/test_app.py
@@ -15,7 +15,7 @@ class TestApp(AsyncHTTPTestCase):
def test_object_view(self):
oid = self.get_url('/object/12345')
- obj = objects.Object(ap_id=oid)
+ obj = objects.APObject(ap_id=oid)
self.app.store.add(obj)
res = self.fetch('/object/12345')
self.assertEqual(res.code, 200)
diff --git a/tests/test_memory_store.py b/tests/test_memory_store.py
index 56f6185..e6b7f1a 100644
--- a/tests/test_memory_store.py
+++ b/tests/test_memory_store.py
@@ -8,12 +8,12 @@ class TestMemoryStore(unittest.TestCase):
def setUp(self):
self.store = memory.Store()
self.oid = 'https://test/object/12345'
- self.obj = objects.Object(ap_id=self.oid)
+ self.obj = objects.APObject(ap_id=self.oid)
self.store.add(self.obj)
def test_add_object(self):
oid = 'https://test/object/12345'
- obj = objects.Object(ap_id=oid)
+ obj = objects.APObject(ap_id=oid)
self.store.add(obj)
self.assertIn(oid, self.store.objects)
diff --git a/tests/test_objects.py b/tests/test_objects.py
index 4f27424..48dfaf1 100644
--- a/tests/test_objects.py
+++ b/tests/test_objects.py
@@ -3,19 +3,19 @@ import unittest
from pyapd import objects
-class TestObjects(unittest.TestCase):
+class TestAPObjects(unittest.TestCase):
def test_activity_from_json(self):
- act = objects.Object.from_jsons('''{
+ act = objects.APObject.from_jsons('''{
"id": "http://example.org/123456",
"type": "object"
}''')
- self.assertIsInstance(act, objects.Object)
+ self.assertIsInstance(act, objects.APObject)
self.assertEqual(act.ap_id, 'http://example.org/123456')
self.assertEqual(act.ap_type, 'object')
def test_activity_to_json(self):
- act = objects.Object(
+ act = objects.APObject(
ap_id="http://example.org/123456",
ap_type="object",
)
diff --git a/tests/test_sqlite_store.py b/tests/test_sqlite_store.py
index 70a4b17..7de7658 100644
--- a/tests/test_sqlite_store.py
+++ b/tests/test_sqlite_store.py
@@ -9,12 +9,12 @@ class TestSqliteStore(unittest.TestCase):
self.store = sqlite.Store(file=':memory:')
self.store.createdb()
self.oid = 'https://test/object/12345'
- self.obj = objects.Object(ap_id=self.oid)
+ self.obj = objects.APObject(ap_id=self.oid)
self.store.add(self.obj)
def test_add_object(self):
oid = 'https://test/object/12345'
- obj = objects.Object(ap_id=oid)
+ obj = objects.APObject(ap_id=oid)
self.store.add(obj)
# self.assertIn('object', self.store.objects)
# self.assertIn(oid, self.store.objects['object'])