コード例 #1
0
    def test_latest_info_product_success(self):
        """
        1.測試拿取上一版的 dependency
        2.正常回傳
        """
        request = request_latest_info_data()
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="latest_info")
        release_vo.validate(api_type="latest_info")

        get_release_info_view_patch = patch.object(
            SearchViewDao,
            'get_release_info',
            side_effect=self.mock_get_release_info_success)
        get_release_info_view_patch.start()
        get_release_info_table_patch = patch.object(
            ReleaseDao,
            'get_release_info',
            side_effect=self.mock_get_release_info_success)
        get_release_info_table_patch.start()

        service = ReleaseService(app_context)
        result, cost_time = service.latest_release_info("product", release_vo)
        assert result == None
        get_release_info_view_patch.stop()
        get_release_info_table_patch.stop()
コード例 #2
0
ファイル: release_api.py プロジェクト: vanceliu/demo_code
def latest_info_func(objectType):
    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="latest_info")

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

    try:
        releaseVo.validate(api_type="latest_info")
        service = ReleaseService(app_context)
        result, cost_time = service.latest_release_info(objectType, 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"))
コード例 #3
0
    def test_latest_info_fail(self):
        """
        1.測試拿取不存在的 release_id 的上一版的 dependency 紀錄
        2.回傳錯誤 389900009
        """
        request = request_latest_info_data()
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="latest_info")
        release_vo.validate(api_type="latest_info")

        get_release_info_patch = patch.object(
            SearchViewDao,
            'get_release_info',
            side_effect=self.mock_get_release_info_not_exist)
        get_release_info_patch.start()
        service = ReleaseService(app_context)
        result, cost_time = service.latest_release_info("project", release_vo)
        assert result == None
        get_release_info_patch.stop()