Exemplo n.º 1
0
def history_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="history_info")

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

    try:
        releaseVo.validate(api_type="history_info")
        service = ReleaseService(app_context)
        result, cost_time = service.get_release_history_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"))
Exemplo n.º 2
0
 def product_history_release_dep_info_fail(self):
     objectType = "product"
     request = request_data_for_history_info()
     release_vo = ReleaseVo()
     release_vo.value_of_import(request, api_type="history_info")
     release_vo.validate(api_type="history_info")
     service = ReleaseService(app_context)
     service.get_release_history_info(objectType, release_vo)
Exemplo n.º 3
0
 def test_dependency_overview(self):
     """
     1.測試 拿取所有依賴套件的資料
     2.正常回傳
     """
     request_data_user = {"user": "******"}
     release_vo = ReleaseVo()
     release_vo.value_of_import(request_data_user, api_type="dependency_overview")
     release_vo.validate(api_type="dependency_overview")
     service = ReleaseService(app_context)
     result, cost_time = service.get_release_overview()
Exemplo n.º 4
0
    def verify_fail(self):
        """
        1.測試對不存在的 release_id verify
        2.回傳錯誤 389900002
        """
        request = request_verify_data()
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="verify")
        release_vo.validate(api_type="verify")

        service = ReleaseService(app_context)
        result, cost_time = service.verify(release_vo)
Exemplo n.º 5
0
    def activate_fail(self):
        """
        1.測試對不存在的 release_id 進行 activate
        2.回傳錯誤 389900009
        """
        request = request_activate_data(running_status=1)
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="activate")
        release_vo.validate(api_type="activate")

        service = ReleaseService(app_context)
        result, cost_time = service.activate(release_vo)
Exemplo n.º 6
0
    def deactive_not_exist_object(self):
        """
        1.測試對不存在的 release_id 進行 deactivate
        2.回傳錯誤 389900002
        """
        request = request_activate_data(running_status=0)
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="activate")
        release_vo.validate(api_type="activate")

        service = ReleaseService(app_context)
        result, cost_time = service.activate(release_vo)
Exemplo n.º 7
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()
Exemplo n.º 8
0
    def test_project_history_release_dep_info_success(self):
        """
        1.測試 拿取專案所依賴的服務或套件歷史紀錄
        2.正常回傳
        """
        objectType = "project"
        request = request_data_for_history_info()
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="history_info")
        release_vo.validate(api_type="history_info")
        service = ReleaseService(app_context)

        check_history_release_dep_info_patch = patch.object(ReleaseDao, "get_data_by_object_id",
                                                            side_effect=self.mock_history_release_info_success)
        check_history_release_dep_info_patch.start()
        result, cost_time = service.get_release_history_info(objectType, release_vo)
        check_history_release_dep_info_patch.stop()
Exemplo n.º 9
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()
Exemplo n.º 10
0
    def test_verify_success(self):
        """
        1.測試 verify
        2.正常回傳
        """

        request = request_verify_data()
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="verify")
        release_vo.validate(api_type="verify")

        update_by_parameters_patch = patch.object(
            ReleaseDao,
            'update_by_parameters',
            side_effect=self.mock_update_by_parameters_success)
        update_by_parameters_patch.start()

        service = ReleaseService(app_context)
        result, cost_time = service.verify(release_vo)
        assert result == "test_release_id"
        update_by_parameters_patch.stop()
Exemplo n.º 11
0
    def test_activate_success(self):
        """
        1.測試 activate
        2.update_by_parameters 正常回傳
        """
        request = request_activate_data(running_status=1)
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="activate")
        release_vo.validate(api_type="activate")

        get_dependency_id_patch = patch.object(
            SearchViewDao,
            'get_dependency_id',
            side_effect=self.mock_get_dependency_id_dicts)
        get_dependency_id_patch.start()
        check_parent_dependency_patch = patch.object(
            ReleaseMappingDao,
            'check_parent_dependency',
            side_effect=self.mock_check_parent_dependency_not_exist)
        check_parent_dependency_patch.start()
        get_release_status_by_id_patch = patch.object(
            ReleaseDao,
            'get_release_status_by_id',
            side_effect=self.mock_get_release_status_by_id)
        get_release_status_by_id_patch.start()
        update_by_parameters_patch = patch.object(
            ReleaseDao,
            'update_by_parameters',
            side_effect=self.mock_update_by_parameters_success)
        update_by_parameters_patch.start()

        service = ReleaseService(app_context)
        result, cost_time = service.activate(release_vo)

        assert result == "test_release_id"
        get_dependency_id_patch.stop()
        update_by_parameters_patch.stop()