1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
from sqlalchemy.testing import assert_raises_message
from sqlalchemy.testing import eq_
from sqlalchemy.testing import fixtures
class _BooleanProcessorTest(fixtures.TestBase):
def test_int_to_bool_none(self):
eq_(self.module.int_to_boolean(None), None)
def test_int_to_bool_zero(self):
eq_(self.module.int_to_boolean(0), False)
def test_int_to_bool_one(self):
eq_(self.module.int_to_boolean(1), True)
def test_int_to_bool_positive_int(self):
eq_(self.module.int_to_boolean(12), True)
def test_int_to_bool_negative_int(self):
eq_(self.module.int_to_boolean(-4), True)
class CBooleanProcessorTest(_BooleanProcessorTest):
__requires__ = ("cextensions",)
@classmethod
def setup_test_class(cls):
from sqlalchemy import cprocessors
cls.module = cprocessors
class _DateProcessorTest(fixtures.TestBase):
def test_date_no_string(self):
assert_raises_message(
ValueError,
"Couldn't parse date string '2012' - value is not a string",
self.module.str_to_date,
2012,
)
def test_datetime_no_string(self):
assert_raises_message(
ValueError,
"Couldn't parse datetime string '2012' - value is not a string",
self.module.str_to_datetime,
2012,
)
def test_time_no_string(self):
assert_raises_message(
ValueError,
"Couldn't parse time string '2012' - value is not a string",
self.module.str_to_time,
2012,
)
def test_date_invalid_string(self):
assert_raises_message(
ValueError,
"Couldn't parse date string: '5:a'",
self.module.str_to_date,
"5:a",
)
def test_datetime_invalid_string(self):
assert_raises_message(
ValueError,
"Couldn't parse datetime string: '5:a'",
self.module.str_to_datetime,
"5:a",
)
def test_time_invalid_string(self):
assert_raises_message(
ValueError,
"Couldn't parse time string: '5:a'",
self.module.str_to_time,
"5:a",
)
class PyDateProcessorTest(_DateProcessorTest):
@classmethod
def setup_test_class(cls):
from sqlalchemy import processors
cls.module = type(
"util",
(object,),
dict(
(k, staticmethod(v))
for k, v in list(processors.py_fallback().items())
),
)
class CDateProcessorTest(_DateProcessorTest):
__requires__ = ("cextensions",)
@classmethod
def setup_test_class(cls):
from sqlalchemy import cprocessors
cls.module = cprocessors
|