# Path: sqlobject/tests/dbtest.py
#     def getcwd():
# def setupClass(soClasses, force=False):
# def speedupSQLiteConnection(connection):
# def getConnection(**kw):
# def getConnectionURI():
#     def installOrClear(cls, soClasses, force=False):
#     def install(cls, soClass):
#     def drop(cls, soClass):
#     def clear(cls, soClass):
#     def setup(cls):
#     def __init__(self, **kw):
# def inserts(cls, data, schema=None):
# def supports(feature):
# def setSQLiteConnectionFactory(TableClass, factory):
# def deprecated_module():
# def setup_module(mod):
# def teardown_module(mod=None):
# def setupLogging():
# def setupCyclicClasses(*classes):
# class InstalledTestDatabase(sqlobject.SQLObject):
# class Dummy(object):


from sqlobject.compat import PY2
from sqlobject.constraints import BadValue, InList, MaxLength, \
    isFloat, isInt, isString, notNull
from sqlobject.tests.dbtest import Dummy, raises
if not PY2:
    # alias for python 3 compatability
    long = int


def test_constraints():
    obj = 'Test object'
    col = Dummy(name='col')
    isString(obj, col, 'blah')
    raises(BadValue, isString, obj, col, 1)
    if PY2:
        # @@: Should this really be an error?
        raises(BadValue, isString, obj, col, u'test!')
    else:
        raises(BadValue, isString, obj, col, b'test!')
    # isString(obj, col, u'test!')

    raises(BadValue, notNull, obj, col, None)
    raises(BadValue, isInt, obj, col, 1.1)
    isInt(obj, col, 1)
    isInt(obj, col, long(1))
    isFloat(obj, col, 1)
    isFloat(obj, col, long(1))
    isFloat(obj, col, 1.2)
    raises(BadValue, isFloat, obj, col, '1.0')

    # @@: Should test isBool, but I don't think isBool is right

    lst = InList(('a', 'b', 'c'))
    lst(obj, col, 'a')

# Path: sqlobject/tests/dbtest.py
#     def getcwd():
# def setupClass(soClasses, force=False):
# def speedupSQLiteConnection(connection):
# def getConnection(**kw):
# def getConnectionURI():
#     def installOrClear(cls, soClasses, force=False):
#     def install(cls, soClass):
#     def drop(cls, soClass):
#     def clear(cls, soClass):
#     def setup(cls):
#     def __init__(self, **kw):
# def inserts(cls, data, schema=None):
# def supports(feature):
# def setSQLiteConnectionFactory(TableClass, factory):
# def deprecated_module():
# def setup_module(mod):
# def teardown_module(mod=None):
# def setupLogging():
# def setupCyclicClasses(*classes):
# class InstalledTestDatabase(sqlobject.SQLObject):
# class Dummy(object):


# Path: sqlobject/tests/test_constraints.py
from sqlobject.compat import PY2
from sqlobject.constraints import BadValue, InList, MaxLength, \
    isFloat, isInt, isString, notNull
from sqlobject.tests.dbtest import Dummy, raises

if not PY2:
    # alias for python 3 compatability
    long = int


def test_constraints():
    obj = 'Test object'
    col = Dummy(name='col')
    isString(obj, col, 'blah')
    raises(BadValue, isString, obj, col, 1)
    if PY2:
        # @@: Should this really be an error?
        raises(BadValue, isString, obj, col, u'test!')
    else:
        raises(BadValue, isString, obj, col, b'test!')
    # isString(obj, col, u'test!')

    raises(BadValue, notNull, obj, col, None)
    raises(BadValue, isInt, obj, col, 1.1)
    isInt(obj, col, 1)
    isInt(obj, col, long(1))
    isFloat(obj, col, 1)
    isFloat(obj, col, long(1))
    isFloat(obj, col, 1.2)
    raises(BadValue, isFloat, obj, col, '1.0')

    # @@: Should test isBool, but I don't think isBool is right

    lst = InList(('a', 'b', 'c'))
    lst(obj, col, 'a')

    raises(BadValue, lst, obj, col, ('a', 'b', 'c'))