Added tests.

This commit is contained in:
Lance Edgar 2013-10-23 10:11:55 -07:00
parent c6f637f655
commit 0b3c78ec19
3 changed files with 49 additions and 0 deletions

7
setup.cfg Normal file
View file

@ -0,0 +1,7 @@
[nosetests]
nocapture = 1
cover-package = sqlalchemy_pervasive
cover-erase = 1
cover-inclusive = 1
cover-html = 1
cover-html-dir = htmlcov

0
tests/__init__.py Normal file
View file

42
tests/test_base.py Normal file
View file

@ -0,0 +1,42 @@
from unittest import TestCase
from mock import Mock
from sqlalchemy.exc import InvalidRequestError
from sqlalchemy_pervasive import base
class PervasiveCompilerTests(TestCase):
def compiler(self):
return base.PervasiveCompiler(dialect=Mock(paramstyle='named'), statement=Mock())
def test_get_select_precolumns(self):
compiler = self.compiler()
select = Mock(_distinct=None, _limit=None, _offset=None)
self.assertEqual(compiler.get_select_precolumns(select), '')
select._distinct = True
self.assertEqual(compiler.get_select_precolumns(select), 'DISTINCT ')
select._distinct = False
select._limit = 10
self.assertEqual(compiler.get_select_precolumns(select), 'TOP 10 ')
select._limit = None
select._offset = 10
self.assertRaises(InvalidRequestError, compiler.get_select_precolumns, select)
def test_limit_clause(self):
compiler = self.compiler()
self.assertEqual(compiler.limit_clause(Mock()), '')
def test_visit_true(self):
compiler = self.compiler()
self.assertEqual(compiler.visit_true(Mock()), '1')
def test_visit_false(self):
compiler = self.compiler()
self.assertEqual(compiler.visit_false(Mock()), '0')