Esempio n. 1
0
def get_detail_func():
    app_context = current_app.config["app_context"]
    response_payload = ReponsePayloadBulider(app_context.messages)

    if request.method == "POST":
        req_data = request.get_json()
        releaseVo = ReleaseVo()
        releaseVo.value_of_import(req_data, api_type="get_release_info")

        if not req_data:
            logger.error("json body is empty")
            return json.jsonify(response_payload.bulid("999900001"))

    try:
        releaseVo.validate(api_type="get_release_info")
        service = ReleaseService(app_context)
        result, cost_time = service.get_specific_releases_info(releaseVo)
        return json.jsonify(
            response_payload.bulid("996600001",
                                   cost_time=cost_time,
                                   data=result))
    except CommonRuntimeException as crex:
        logger.error(traceback.format_exc())
        return json.jsonify((response_payload.bulid_from_exception(crex)))
    except AssertionError as ae:
        return json.jsonify((response_payload.bulid(ae.args[0])))
    except:
        logger.error(traceback.format_exc())
        return json.jsonify(response_payload.bulid("999999999"))
Esempio n. 2
0
    def test_get_specific_releases_info(self):
        """
        1.測試 拿取指定release_id的release詳細資料
        2.正常回傳
        """
        request = request_data_for_get_spec_release_detail()
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="get_release_info")
        release_vo.validate(api_type="get_release_info")
        service = ReleaseService(app_context)

        check_search_by_id_list_patch = patch.object(ReleaseDao, "search_by_id_list",
                                                     side_effect=self.mock_search_by_id_list)
        check_search_by_id_list_patch.start()
        result, cost_time = service.get_specific_releases_info(release_vo)
        check_search_by_id_list_patch.stop()