def create_from_dictionary(self, datas): """Return a populated object ResponseCode from dictionary datas """ if "code" not in datas: raise ValueError("A response code must contain a code in \"%s\"." % repr(datas)) code = ObjectResponseCode() self.set_common_datas(code, str(datas["code"]), datas) code.code = int(datas["code"]) if "message" in datas: code.message = str(datas["message"]) elif code.code in self.default_messages.keys(): code.message = self.default_messages[code.code] if "generic" in datas: code.generic = to_boolean(datas["generic"]) return code
def test_method_message(self): method = Method() code = ResponseCode() code.code = 100 code.message = "foo" method.code = 100 method.response_codes = [code] self.assertEqual("foo", method.message)
def create_from_dictionary(self, datas): """Return a populated object ResponseCode from dictionary datas """ if "code" not in datas: raise ValueError("A response code must contain a code in \"%s\"." % repr(datas)) code = ObjectResponseCode() self.set_common_datas(code, str(datas["code"]), datas) code.code = int(datas["code"]) if "message" in datas: code.message = str(datas["message"]) elif code.code in self.default_messages.keys(): code.message = self.default_messages[code.code] if "generic" in datas: code.generic = to_bool(datas["generic"]) return code
def test_method_message__failled_when_no_code_found(self): method = Method() code = ResponseCode() code.code = 100 code.message = "foo" method.code = 300 method.response_codes = [code] with self.assertRaises(ValueError): method.message
def test_response_code(self): parameter = ResponseCode() parameter.name = "a" parameter.description = "b" parameter.code = 300 parameter.message = "c" parameter_dto = ResponseCodeDto(parameter) self.assertEqual("a", parameter_dto.name) self.assertEqual("b", parameter_dto.description) self.assertEqual(300, parameter_dto.code) self.assertEqual("c", parameter_dto.message)