Exemplo n.º 1
0
 def test_should_allow_integer(self):
     self.assertEqual(coerce_parameters(0), 0)
     self.assertEqual(coerce_parameters(0x7F), 0x7F)
     self.assertEqual(coerce_parameters(0x7FFF), 0x7FFF)
     self.assertEqual(coerce_parameters(0x7FFFFFFF), 0x7FFFFFFF)
     self.assertEqual(coerce_parameters(0x7FFFFFFFFFFFFFFF),
                      0x7FFFFFFFFFFFFFFF)
Exemplo n.º 2
0
 def test_should_allow_dict(self):
     self.assertEqual(coerce_parameters({}), {})
     self.assertEqual(
         coerce_parameters({
             u"one": 1,
             u"two": 1,
             u"three": 1
         }), {
             u"one": 1,
             u"two": 1,
             u"three": 1
         })
     self.assertEqual(
         coerce_parameters({
             u"list": [1, 2, 3, [4, 5, 6]],
             u"dict": {
                 u"a": 1,
                 u"b": 2
             }
         }), {
             u"list": [1, 2, 3, [4, 5, 6]],
             u"dict": {
                 u"a": 1,
                 u"b": 2
             }
         })
Exemplo n.º 3
0
 def test_should_disallow_object(self):
     with self.assertRaises(TypeError):
         coerce_parameters(object())
     with self.assertRaises(TypeError):
         coerce_parameters(uuid4())
Exemplo n.º 4
0
 def test_should_allow_list(self):
     self.assertEqual(coerce_parameters([]), [])
     self.assertEqual(coerce_parameters([1, 2, 3]), [1, 2, 3])
Exemplo n.º 5
0
 def test_should_allow_bytes(self):
     self.assertEqual(coerce_parameters(bytearray()), bytearray())
     self.assertEqual(coerce_parameters(bytearray([1, 2, 3])),
                      bytearray([1, 2, 3]))
Exemplo n.º 6
0
 def test_should_allow_string(self):
     self.assertEqual(coerce_parameters(u""), u"")
     self.assertEqual(coerce_parameters(u"hello, world"), u"hello, world")
Exemplo n.º 7
0
 def test_should_allow_float(self):
     self.assertEqual(coerce_parameters(0.0), 0.0)
     self.assertEqual(coerce_parameters(3.1415926), 3.1415926)
Exemplo n.º 8
0
 def test_should_disallow_oversized_integer(self):
     with self.assertRaises(ValueError):
         coerce_parameters(0x10000000000000000)
     with self.assertRaises(ValueError):
         coerce_parameters(-0x10000000000000000)
Exemplo n.º 9
0
 def test_should_allow_boolean(self):
     self.assertTrue(coerce_parameters(True))
     self.assertFalse(coerce_parameters(False))
Exemplo n.º 10
0
 def test_should_allow_none(self):
     self.assertIsNone(coerce_parameters(None))