added tests, pep8 format
This commit is contained in:
parent
9de0ad3e82
commit
bbaf65f77c
@ -5,6 +5,7 @@ from dataset import connect
|
|||||||
from dataset.util import DatasetException
|
from dataset.util import DatasetException
|
||||||
from sample_data import TEST_DATA
|
from sample_data import TEST_DATA
|
||||||
|
|
||||||
|
|
||||||
class DatabaseTestCase(unittest.TestCase):
|
class DatabaseTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -113,7 +114,25 @@ class TableTestCase(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
assert False, 'we should not reach else block, no exception raised!'
|
assert False, 'we should not reach else block, no exception raised!'
|
||||||
|
|
||||||
|
def test_columns(self):
|
||||||
|
cols = self.tbl.columns
|
||||||
|
assert isinstance(cols, set), 'columns should be a set'
|
||||||
|
assert len(cols) == 4, 'column count mismatch'
|
||||||
|
assert 'date' in cols and 'temperature' in cols and 'place' in cols
|
||||||
|
|
||||||
|
def test_iter(self):
|
||||||
|
c = 0
|
||||||
|
for row in self.tbl:
|
||||||
|
c += 1
|
||||||
|
assert c == len(self.tbl)
|
||||||
|
|
||||||
|
def test_update(self):
|
||||||
|
self.tbl.upsert({
|
||||||
|
'date': datetime(2011, 01, 02),
|
||||||
|
'temperature': -10,
|
||||||
|
'place': 'Berlin'},
|
||||||
|
['place']
|
||||||
|
)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user