Exemplo n.º 1
0
 def test_accepts_string_string(self):
     data = 'spam'
     result = _typecheck_or_convert_data(data, 'string')
     self.assertEqual(result, data)
Exemplo n.º 2
0
 def test_accepts_pyobj_pyobj(self):
     data = {'spam': ['ham'], 'eggs': True}
     result = _typecheck_or_convert_data(data, 'pyobj')
     self.assertEqual(result, data)
Exemplo n.º 3
0
 def test_accepts_bytes_raw(self):
     data = b'spam'
     result = _typecheck_or_convert_data(data, 'raw')
     self.assertEqual(result, data)
Exemplo n.º 4
0
 def test_accepts_list_of_bytes_multipart(self):
     data = [b'spam', b'ham']
     result = _typecheck_or_convert_data(data, 'multipart')
     self.assertEqual(result, data)
Exemplo n.º 5
0
 def test_turns_None_into_empty_bytestring_multipart(self):
     result = _typecheck_or_convert_data(None, 'multipart')
     self.assertEqual(result, [b''])
Exemplo n.º 6
0
 def test_wraps_bytestring_into_list_multipart(self):
     data = b'spam'
     result = _typecheck_or_convert_data(data, 'multipart')
     self.assertEqual(result, [data])
Exemplo n.º 7
0
 def test_turns_None_into_empty_bytestring_raw(self):
     result = _typecheck_or_convert_data(None, 'raw')
     self.assertEqual(result, b'')
Exemplo n.º 8
0
 def test_rejects_invalid_send_type(self):
     data = {'spam': ['ham'], 'eggs': True}
     with self.assertRaises(ValueError):
         _typecheck_or_convert_data(data, 'invalid_send_type')
Exemplo n.º 9
0
 def test_rejects_pyobj_string(self):
     data = {'spam': ['ham'], 'eggs': True}
     with self.assertRaises(TypeError):
         _typecheck_or_convert_data(data, 'string')
Exemplo n.º 10
0
 def test_rejects_string_multipart(self):
     data = [b'spam', 'ham']
     with self.assertRaises(TypeError):
         _typecheck_or_convert_data(data, 'multipart')
Exemplo n.º 11
0
 def test_rejects_string_raw(self):
     data = 'spam'
     with self.assertRaises(TypeError):
         _typecheck_or_convert_data(data, 'raw')