コード例 #1
0
 def test_unregister(self):
     with self.assertRaises(SerializerNotInstalled):
         unregister("nonexisting")
     registry.encode("foo", serializer="pickle")
     unregister("pickle")
     with self.assertRaises(SerializerNotInstalled):
         registry.encode("foo", serializer="pickle")
     register_pickle()
コード例 #2
0
ファイル: test_serialization.py プロジェクト: uceo/uceo-2015
 def test_content_type_encoding(self):
     # Using the 'raw' serializer
     self.assertEqual(unicode_string_as_utf8, registry.encode(unicode_string, serializer="raw")[-1])
     self.assertEqual(latin_string_as_utf8, registry.encode(latin_string, serializer="raw")[-1])
     # And again w/o a specific serializer to check the
     # code where we force unicode objects into a string.
     self.assertEqual(unicode_string_as_utf8, registry.encode(unicode_string)[-1])
     self.assertEqual(latin_string_as_utf8, registry.encode(latin_string)[-1])
コード例 #3
0
ファイル: test_serialization.py プロジェクト: EnTeQuAk/kombu
 def test_unregister(self):
     self.assertRaises(SerializerNotInstalled,
                       unregister, "nonexisting")
     registry.encode("foo", serializer="pickle")
     unregister("pickle")
     self.assertRaises(SerializerNotInstalled,
                       registry.encode, "foo", serializer="pickle")
     register_pickle()
コード例 #4
0
 def test_unregister(self):
     with self.assertRaises(SerializerNotInstalled):
         unregister('nonexisting')
     registry.encode('foo', serializer='pickle')
     unregister('pickle')
     with self.assertRaises(SerializerNotInstalled):
         registry.encode('foo', serializer='pickle')
     register_pickle()
コード例 #5
0
 def test_unregister(self):
     with self.assertRaises(SerializerNotInstalled):
         unregister('nonexisting')
     registry.encode('foo', serializer='pickle')
     unregister('pickle')
     with self.assertRaises(SerializerNotInstalled):
         registry.encode('foo', serializer='pickle')
     register_pickle()
コード例 #6
0
 def test_unregister(self):
     with self.assertRaises(SerializerNotInstalled):
         unregister("nonexisting")
     registry.encode("foo", serializer="pickle")
     unregister("pickle")
     with self.assertRaises(SerializerNotInstalled):
         registry.encode("foo", serializer="pickle")
     register_pickle()
コード例 #7
0
ファイル: test_serialization.py プロジェクト: jason790/kombu
 def test_unregister(self):
     self.assertRaises(SerializerNotInstalled, unregister, "nonexisting")
     registry.encode("foo", serializer="pickle")
     unregister("pickle")
     self.assertRaises(SerializerNotInstalled,
                       registry.encode,
                       "foo",
                       serializer="pickle")
     register_pickle()
コード例 #8
0
 def test_content_type_encoding(self):
     # Using the "raw" serializer
     self.assertEqual(unicode_string_as_utf8,
                      registry.encode(unicode_string, serializer="raw")[-1])
     self.assertEqual(latin_string_as_utf8,
                      registry.encode(latin_string, serializer="raw")[-1])
     # And again w/o a specific serializer to check the
     # code where we force unicode objects into a string.
     self.assertEqual(unicode_string_as_utf8,
                      registry.encode(unicode_string)[-1])
     self.assertEqual(latin_string_as_utf8,
                      registry.encode(latin_string)[-1])
コード例 #9
0
ファイル: test_serialization.py プロジェクト: jason790/kombu
 def test_json_encode(self):
     self.assertEquals(
         registry.decode(registry.encode(py_data, serializer="json")[-1],
                         content_type='application/json',
                         content_encoding='utf-8'),
         registry.decode(json_data,
                         content_type='application/json',
                         content_encoding='utf-8'))
コード例 #10
0
ファイル: test_serialization.py プロジェクト: romand/kombu
 def test_msgpack_decode(self):
     register_msgpack()
     decoded = registry.decode(
                 registry.encode(msgpack_py_data,
                     serializer='msgpack')[-1],
                 content_type='application/x-msgpack',
                 content_encoding='binary')
     self.assertEqual(msgpack_py_data, decoded)
コード例 #11
0
ファイル: test_serialization.py プロジェクト: adityar7/kombu
 def test_msgpack_decode(self):
     register_msgpack()
     decoded = registry.decode(
         registry.encode(msgpack_py_data, serializer='msgpack')[-1],
         content_type='application/x-msgpack',
         content_encoding='binary',
     )
     self.assertEqual(msgpack_py_data, decoded)
コード例 #12
0
 def test_json_encode(self):
     self.assertEqual(registry.decode(
                           registry.encode(py_data, serializer='json')[-1],
                           content_type='application/json',
                           content_encoding='utf-8'),
                       registry.decode(
                           json_data,
                           content_type='application/json',
                           content_encoding='utf-8'))
コード例 #13
0
 def test_yaml_encode(self):
     register_yaml()
     self.assertEqual(
         registry.decode(registry.encode(py_data, serializer="yaml")[-1],
                         content_type='application/x-yaml',
                         content_encoding='utf-8'),
         registry.decode(yaml_data,
                         content_type='application/x-yaml',
                         content_encoding='utf-8'))
コード例 #14
0
ファイル: test_serialization.py プロジェクト: uceo/uceo-2015
 def test_json_encode(self):
     self.assertEqual(
         registry.decode(
             registry.encode(py_data, serializer="json")[-1],
             content_type="application/json",
             content_encoding="utf-8",
         ),
         registry.decode(json_data, content_type="application/json", content_encoding="utf-8"),
     )
コード例 #15
0
ファイル: test_serialization.py プロジェクト: uceo/uceo-2015
 def test_yaml_encode(self):
     register_yaml()
     self.assertEqual(
         registry.decode(
             registry.encode(py_data, serializer="yaml")[-1],
             content_type="application/x-yaml",
             content_encoding="utf-8",
         ),
         registry.decode(yaml_data, content_type="application/x-yaml", content_encoding="utf-8"),
     )
コード例 #16
0
 def test_yaml_encode(self):
     register_yaml()
     self.assertEqual(registry.decode(
                           registry.encode(py_data, serializer='yaml')[-1],
                           content_type='application/x-yaml',
                           content_encoding='utf-8'),
                       registry.decode(
                           yaml_data,
                           content_type='application/x-yaml',
                           content_encoding='utf-8'))
コード例 #17
0
ファイル: test_serialization.py プロジェクト: EnTeQuAk/kombu
 def test_msgpack_encode(self):
     register_msgpack()
     self.assertEquals(registry.decode(
             registry.encode(msgpack_py_data, serializer="msgpack")[-1],
             content_type='application/x-msgpack',
             content_encoding='binary'),
             registry.decode(
                 msgpack_data,
                 content_type='application/x-msgpack',
                 content_encoding='binary'))
コード例 #18
0
ファイル: test_serialization.py プロジェクト: jason790/kombu
 def test_yaml_encode(self):
     register_yaml()
     try:
         __import__("yaml")
     except ImportError:
         say("* PyYAML not installed, will not execute related tests.")
         raise SkipTest("PyYAML not installed")
     self.assertEquals(
         registry.decode(registry.encode(py_data, serializer="yaml")[-1],
                         content_type='application/x-yaml',
                         content_encoding='utf-8'),
         registry.decode(yaml_data,
                         content_type='application/x-yaml',
                         content_encoding='utf-8'))
コード例 #19
0
 def test_yaml_encode(self):
     try:
         import yaml
     except ImportError:
         say("* PyYAML not installed, will not execute related tests.")
         raise SkipTest("PyYAML not installed")
     self.assertEquals(registry.decode(
                           registry.encode(py_data, serializer="yaml")[-1],
                           content_type='application/x-yaml',
                           content_encoding='utf-8'),
                       registry.decode(
                           yaml_data,
                           content_type='application/x-yaml',
                           content_encoding='utf-8'))
コード例 #20
0
 def test_msgpack_encode(self):
     try:
         import msgpack
     except ImportError:
         say("* msgpack-python not installed, will not execute "
             "related tests.")
         raise SkipTest("msgpack-python not installed")
     self.assertEquals(registry.decode(
             registry.encode(msgpack_py_data, serializer="msgpack")[-1],
             content_type='application/x-msgpack',
             content_encoding='binary'),
             registry.decode(
                 msgpack_data,
                 content_type='application/x-msgpack',
                 content_encoding='binary'))
コード例 #21
0
ファイル: test_serialization.py プロジェクト: jason790/kombu
 def test_msgpack_encode(self):
     register_msgpack()
     try:
         __import__("msgpack")
     except ImportError:
         say("* msgpack-python not installed, will not execute "
             "related tests.")
         raise SkipTest("msgpack-python not installed")
     self.assertEquals(
         registry.decode(registry.encode(msgpack_py_data,
                                         serializer="msgpack")[-1],
                         content_type='application/x-msgpack',
                         content_encoding='binary'),
         registry.decode(msgpack_data,
                         content_type='application/x-msgpack',
                         content_encoding='binary'))
コード例 #22
0
 def test_pickle_encode(self):
     self.assertEqual(pickle_data,
                       registry.encode(py_data,
                           serializer='pickle')[-1])
コード例 #23
0
ファイル: test_serialization.py プロジェクト: uceo/uceo-2015
 def test_pickle_encode(self):
     self.assertEqual(pickle.loads(pickle_data), pickle.loads(registry.encode(py_data, serializer="pickle")[-1]))
コード例 #24
0
ファイル: test_serialization.py プロジェクト: jason790/kombu
 def test_pickle_encode(self):
     self.assertEquals(pickle_data,
                       registry.encode(py_data, serializer="pickle")[-1])
コード例 #25
0
 def test_encode_missing(self):
     with self.assertRaises(SerializerNotInstalled):
         registry.encode('foo', serializer='nonexisting')
コード例 #26
0
 def test_pickle_encode(self):
     self.assertEqual(
         pickle.loads(pickle_data),
         pickle.loads(registry.encode(py_data, serializer='pickle')[-1]),
     )
コード例 #27
0
 def test_encode__no_serializer(self):
     ctyp, cenc, data = registry.encode(str_to_bytes('foo'))
     self.assertEqual(ctyp, 'application/data')
     self.assertEqual(cenc, 'binary')
コード例 #28
0
 def test_encode_missing(self):
     with self.assertRaises(SerializerNotInstalled):
         registry.encode('foo', serializer='nonexisting')
コード例 #29
0
 def test_encode__no_serializer(self):
     ctyp, cenc, data = registry.encode(str_to_bytes('foo'))
     self.assertEqual(ctyp, 'application/data')
     self.assertEqual(cenc, 'binary')