~ubuntu-branches/debian/jessie/sqlalchemy/jessie

« back to all changes in this revision

Viewing changes to test/engine/test_processors.py

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski, Jakub Wilk, Piotr Ożarowski
  • Date: 2013-07-06 20:53:52 UTC
  • mfrom: (1.4.23) (16.1.17 experimental)
  • Revision ID: package-import@ubuntu.com-20130706205352-ryppl1eto3illd79
Tags: 0.8.2-1
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Piotr Ożarowski ]
* New upstream release
* Upload to unstable
* Build depend on python3-all instead of -dev, extensions are not built for
  Python 3.X 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from test.lib import fixtures
2
 
from test.lib.testing import assert_raises_message
 
1
from sqlalchemy.testing import fixtures
 
2
from sqlalchemy.testing import assert_raises_message, eq_
3
3
 
4
 
from sqlalchemy import processors
5
 
try:
6
 
    from sqlalchemy import cprocessors
7
 
except ImportError:
8
 
    cprocessors = None
9
4
 
10
5
class _DateProcessorTest(fixtures.TestBase):
11
6
    def test_date_no_string(self):
52
47
 
53
48
 
54
49
class PyDateProcessorTest(_DateProcessorTest):
55
 
    module = processors
56
 
 
 
50
    @classmethod
 
51
    def setup_class(cls):
 
52
        from sqlalchemy import processors
 
53
        cls.module = type("util", (object,),
 
54
                dict(
 
55
                    (k, staticmethod(v))
 
56
                        for k, v in processors.py_fallback().items()
 
57
                )
 
58
            )
57
59
 
58
60
class CDateProcessorTest(_DateProcessorTest):
59
61
    __requires__ = ('cextensions',)
60
 
    module = cprocessors
 
62
    @classmethod
 
63
    def setup_class(cls):
 
64
        from sqlalchemy import cprocessors
 
65
        cls.module = cprocessors
 
66
 
 
67
 
 
68
class _DistillArgsTest(fixtures.TestBase):
 
69
    def test_distill_none(self):
 
70
        eq_(
 
71
            self.module._distill_params(None, None),
 
72
            []
 
73
        )
 
74
 
 
75
    def test_distill_no_multi_no_param(self):
 
76
        eq_(
 
77
            self.module._distill_params((), {}),
 
78
            []
 
79
        )
 
80
 
 
81
    def test_distill_dict_multi_none_param(self):
 
82
        eq_(
 
83
            self.module._distill_params(None, {"foo": "bar"}),
 
84
            [{"foo": "bar"}]
 
85
        )
 
86
 
 
87
    def test_distill_dict_multi_empty_param(self):
 
88
        eq_(
 
89
            self.module._distill_params((), {"foo": "bar"}),
 
90
            [{"foo": "bar"}]
 
91
        )
 
92
 
 
93
    def test_distill_single_dict(self):
 
94
        eq_(
 
95
            self.module._distill_params(({"foo": "bar"},), {}),
 
96
            [{"foo": "bar"}]
 
97
        )
 
98
 
 
99
    def test_distill_single_list_strings(self):
 
100
        eq_(
 
101
            self.module._distill_params((["foo", "bar"],), {}),
 
102
            [["foo", "bar"]]
 
103
        )
 
104
 
 
105
    def test_distill_single_list_tuples(self):
 
106
        eq_(
 
107
            self.module._distill_params(([("foo", "bar"), ("bat", "hoho")],), {}),
 
108
            [('foo', 'bar'), ('bat', 'hoho')]
 
109
        )
 
110
 
 
111
    def test_distill_single_list_tuple(self):
 
112
        eq_(
 
113
            self.module._distill_params(([("foo", "bar")],), {}),
 
114
            [('foo', 'bar')]
 
115
        )
 
116
 
 
117
    def test_distill_multi_list_tuple(self):
 
118
        eq_(
 
119
            self.module._distill_params(
 
120
                ([("foo", "bar")], [("bar", "bat")]),
 
121
                {}
 
122
            ),
 
123
            ([('foo', 'bar')], [('bar', 'bat')])
 
124
        )
 
125
 
 
126
    def test_distill_multi_strings(self):
 
127
        eq_(
 
128
            self.module._distill_params(("foo", "bar"), {}),
 
129
            [('foo', 'bar')]
 
130
        )
 
131
 
 
132
    def test_distill_single_list_dicts(self):
 
133
        eq_(
 
134
            self.module._distill_params(([{"foo": "bar"}, {"foo": "hoho"}],), {}),
 
135
            [{'foo': 'bar'}, {'foo': 'hoho'}]
 
136
        )
 
137
 
 
138
    def test_distill_single_string(self):
 
139
        eq_(
 
140
            self.module._distill_params(("arg",), {}),
 
141
            [["arg"]]
 
142
        )
 
143
 
 
144
    def test_distill_multi_string_tuple(self):
 
145
        eq_(
 
146
            self.module._distill_params((("arg", "arg"),), {}),
 
147
            [("arg", "arg")]
 
148
        )
 
149
 
 
150
 
 
151
 
 
152
class PyDistillArgsTest(_DistillArgsTest):
 
153
    @classmethod
 
154
    def setup_class(cls):
 
155
        from sqlalchemy.engine import util
 
156
        cls.module = type("util", (object,),
 
157
                dict(
 
158
                    (k, staticmethod(v))
 
159
                        for k, v in util.py_fallback().items()
 
160
                )
 
161
        )
 
162
 
 
163
class CDistillArgsTest(_DistillArgsTest):
 
164
    __requires__ = ('cextensions', )
 
165
    @classmethod
 
166
    def setup_class(cls):
 
167
        from sqlalchemy import cutils as util
 
168
        cls.module = util