using in-memory db

This commit is contained in:
ari committed 2022-08-31 15:44:52 -04:00
1 parent 00c234541d
commit 499752e02f
6 files changed
+51 -115

No files matched your search

+3 -14
View File
@@ -1,23 +1,12 @@
from pathlib import Path
from src.automations.errors import DBDataError
from src.automations.errors import DBDataError, RepeatedAutomationId
from src.automations.types import ExtenededAutomation
from .utils import TestWithDB
class db_tests(TestWithDB):
def test_db_creation(self):
with self.db.get_cur() as cur:
cur.execute("SELECT name FROM sqlite_master WHERE type ='table'")
tables = cur.fetchall()
self.assertListEqual(tables, [("autos",)])
self.db.create_db()
with self.db.get_cur() as cur:
cur.execute("SELECT name FROM sqlite_master WHERE type ='table'")
tables = cur.fetchall()
self.assertListEqual(tables, [("autos",)])
def test_insert_automations(self):
originals = [
ExtenededAutomation(
@@ -61,7 +50,7 @@ class db_tests(TestWithDB):
configuration_key=["automation"],
),
]
with self.assertRaises(DBDataError) as err:
with self.assertRaises(RepeatedAutomationId):
self.db.insert_automations(originals)
autos = list(self.db.list_automations(0, 10))
self.assertEqual(len(autos), 0)
self.assertEqual(len(autos), 1)