summaryrefslogtreecommitdiff
path: root/test/engine/test_processors.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-08-07 15:23:11 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-08-07 15:23:11 -0400
commit819ec8e13f03297a7af2fb5d7db5f742a5a1357d (patch)
treece28705537cd3ad1a8125d2557a383c26cee63ac /test/engine/test_processors.py
parentc13d4f613faa0590db713c4491781012163bc5f0 (diff)
downloadsqlalchemy-819ec8e13f03297a7af2fb5d7db5f742a5a1357d.tar.gz
- add new C extension "utils", so far includes distill_params
- repair test_processors which wasn't hitting the python functions - add another suite to test_processors that does distill_params
Diffstat (limited to 'test/engine/test_processors.py')
-rw-r--r--test/engine/test_processors.py126
1 files changed, 117 insertions, 9 deletions
diff --git a/test/engine/test_processors.py b/test/engine/test_processors.py
index d6b994e78..d05de6902 100644
--- a/test/engine/test_processors.py
+++ b/test/engine/test_processors.py
@@ -1,11 +1,6 @@
from test.lib import fixtures
-from test.lib.testing import assert_raises_message
+from test.lib.testing import assert_raises_message, eq_
-from sqlalchemy import processors
-try:
- from sqlalchemy import cprocessors
-except ImportError:
- cprocessors = None
class _DateProcessorTest(fixtures.TestBase):
def test_date_no_string(self):
@@ -52,9 +47,122 @@ class _DateProcessorTest(fixtures.TestBase):
class PyDateProcessorTest(_DateProcessorTest):
- module = processors
-
+ @classmethod
+ def setup_class(cls):
+ from sqlalchemy import processors
+ cls.module = type("util", (object,),
+ dict(
+ (k, staticmethod(v))
+ for k, v in processors.py_fallback().items()
+ )
+ )
class CDateProcessorTest(_DateProcessorTest):
__requires__ = ('cextensions',)
- module = cprocessors
+ @classmethod
+ def setup_class(cls):
+ from sqlalchemy import cprocessors
+ cls.module = cprocessors
+
+
+class _DistillArgsTest(fixtures.TestBase):
+ def test_distill_none(self):
+ eq_(
+ self.module._distill_params(None, None),
+ []
+ )
+
+ def test_distill_no_multi_no_param(self):
+ eq_(
+ self.module._distill_params((), {}),
+ []
+ )
+
+ def test_distill_dict_multi_none_param(self):
+ eq_(
+ self.module._distill_params(None, {"foo": "bar"}),
+ [{"foo": "bar"}]
+ )
+
+ def test_distill_dict_multi_empty_param(self):
+ eq_(
+ self.module._distill_params((), {"foo": "bar"}),
+ [{"foo": "bar"}]
+ )
+
+ def test_distill_single_dict(self):
+ eq_(
+ self.module._distill_params(({"foo": "bar"},), {}),
+ [{"foo": "bar"}]
+ )
+
+ def test_distill_single_list_strings(self):
+ eq_(
+ self.module._distill_params((["foo", "bar"],), {}),
+ [["foo", "bar"]]
+ )
+
+ def test_distill_single_list_tuples(self):
+ eq_(
+ self.module._distill_params(([("foo", "bar"), ("bat", "hoho")],), {}),
+ [('foo', 'bar'), ('bat', 'hoho')]
+ )
+
+ def test_distill_single_list_tuple(self):
+ eq_(
+ self.module._distill_params(([("foo", "bar")],), {}),
+ [('foo', 'bar')]
+ )
+
+ def test_distill_multi_list_tuple(self):
+ eq_(
+ self.module._distill_params(
+ ([("foo", "bar")], [("bar", "bat")]),
+ {}
+ ),
+ ([('foo', 'bar')], [('bar', 'bat')])
+ )
+
+ def test_distill_multi_strings(self):
+ eq_(
+ self.module._distill_params(("foo", "bar"), {}),
+ [('foo', 'bar')]
+ )
+
+ def test_distill_single_list_dicts(self):
+ eq_(
+ self.module._distill_params(([{"foo": "bar"}, {"foo": "hoho"}],), {}),
+ [{'foo': 'bar'}, {'foo': 'hoho'}]
+ )
+
+ def test_distill_single_string(self):
+ eq_(
+ self.module._distill_params(("arg",), {}),
+ [["arg"]]
+ )
+
+ def test_distill_multi_string_tuple(self):
+ eq_(
+ self.module._distill_params((("arg", "arg"),), {}),
+ [("arg", "arg")]
+ )
+
+
+
+class PyDistillArgsTest(_DistillArgsTest):
+ @classmethod
+ def setup_class(cls):
+ from sqlalchemy.engine import util
+ cls.module = type("util", (object,),
+ dict(
+ (k, staticmethod(v))
+ for k, v in util.py_fallback().items()
+ )
+ )
+
+class CDistillArgsTest(_DistillArgsTest):
+ __requires__ = ('cextensions', )
+ @classmethod
+ def setup_class(cls):
+ from sqlalchemy import cutils as util
+ cls.module = util