You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
isso/specs/test_db.py

37 lines
798 B

import shutil
import tempfile
import unittest
from isso.comments import Comment
from isso.db import SQLite
class TestSQLite(unittest.TestCase):
def setUp(self):
self.path = tempfile.mkdtemp()
self.db = SQLite()
self.db.initialize({'DATA_DIR': self.path})
def test_add(self):
self.db.add('/', Comment(text='Foo'))
self.db.add('/', Comment(text='Bar'))
self.db.add('/path/', Comment(text='Baz'))
rv = list(self.db.retrieve('/'))
assert rv[0].id == 2
assert rv[0].text == 'Bar'
assert rv[1].id == 1
assert rv[1].text == 'Foo'
rv = list(self.db.retrieve('/path/'))
assert rv[0].id == 1
assert rv[0].text == 'Baz'
def tearDown(self):
shutil.rmtree(self.path)