def test_invalid(self):
     'Неверное значение'
     
     args    = {'a' : 'hehe', 'b' : '-8.365'}
     accepts = {'a' : int, 'b' : (float, positive), 'c' : {'d' : float, 'e' : int}}
     
     self.assertRaises(Exception, validate, args, accepts)
     
     try:
         validate(args, accepts)
     except Exception, error:
         self.assertEqual(dict(error.args), {'a' : 'int', 'b' : 'positive', 'c' : 'absent', 'c.d' : 'absent', 'c.e' : 'absent'})
 def test_no_dictionary(self):
     'Скалярное значение вместо словаря'
     
     args    = {'a' : '15'}
     accepts = {'a' : {'b' : int, 'c' : float}}
     
     self.assertRaises(Exception, validate, args, accepts)
     
     try:
         validate(args, accepts)
     except Exception, error:
         self.assertEqual(error.args, (('a.c', 'absent'), ('a.b', 'absent')))
 def test_absent(self):
     'Отсутствие обязательного параметра'
     
     args = {'a' : '5'}
     accepts = {'a' : int, 'b' : {'c' : (float, unsigned), 'd' : float}}
     
     self.assertRaises(Exception, validate, args, accepts)
     
     try:
         validate(args, accepts)
     except Exception, error:
         self.assertEqual(error.args, (('b', 'absent'), ('b.c', 'absent'), ('b.d', 'absent')))
 def test_positive(self):
     'Положительный тест'
     
     args = {'a' : '5', 'b' : {'c' : '8.365', 'd' : '-7.15'}}
     accepts = {'a' : int, 'b' : {'c' : (float, unsigned), 'd' : float}}
     
     self.assertEqual(validate(args, accepts), {'a' : 5, 'b' : {'c' : 8.365, 'd' : -7.15}})