Exemplo n.º 1
0
    def test_validate_required(self):
        tm = TeaModel()
        tm.validate()
        tm.to_map()
        tm.from_map()

        n = tm.validate_required('test', 'prop_name')
        self.assertIsNone(n)

        try:
            tm.validate_required(None, 'prop_name')
            assert False
        except Exception as e:
            self.assertEqual('"prop_name" is required.', str(e))
Exemplo n.º 2
0
 def from_map(
         model: TeaModel,
         dic: Dict[str, Any]
 ) -> TeaModel:
     if isinstance(model, TeaModel):
         try:
             return model.from_map(dic)
         except Exception:
             model._map = dic
             return model
     else:
         return model