From 8ec9be0c8009b86affe588de774119c5f8e149fa Mon Sep 17 00:00:00 2001 From: Diego Roversi Date: Fri, 26 Apr 2019 16:43:23 +0200 Subject: sqlite3 implentation of store --- tests/test_sqlite_store.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/test_sqlite_store.py (limited to 'tests') diff --git a/tests/test_sqlite_store.py b/tests/test_sqlite_store.py new file mode 100644 index 0000000..849c7a2 --- /dev/null +++ b/tests/test_sqlite_store.py @@ -0,0 +1,32 @@ +import unittest + +from pyapd import objects +from pyapd.stores import sqlite, exceptions + + +class TestSqliteStore(unittest.TestCase): + def setUp(self): + self.store = sqlite.Store() + self.oid = 'https://test/object/12345' + self.obj = objects.Object(id=self.oid) + self.store.add(self.obj) + + def test_add_object(self): + oid = 'https://test/object/12345' + obj = objects.Object(id=oid) + self.store.add(obj) + self.assertIn('object', self.store.objects) + self.assertIn(oid, self.store.objects['object']) + + def test_get_object(self): + res = self.store.get('object', self.oid) + self.assertEqual(res, self.obj) + + def test_get_object_not_existing(self): + oid = 'https://test/object/does_not_exist' + with self.assertRaises(exceptions.DoesNotExist): + self.store.get('object', oid) + + def test_get_object_wrong_type(self): + with self.assertRaises(exceptions.UnknownObjectType): + self.store.get('no_such_type', self.oid) -- cgit v1.2.3