Esempio n. 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()
Esempio n. 2
0
    def test_modify_success(self):
        """
        1.測試 modify
        2.正常回傳
        """
        request = request_modify_data()
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="modify_release_info")
        release_vo.validate(api_type="modify_release_info")

        modify_dependency_by_release_id_patch = patch.object(
            ReleaseMappingDao,
            'modify_dependency_by_release_id',
            side_effect=self.mock_modify_dependency_by_release_id_success)
        modify_dependency_by_release_id_patch.start()
        get_status_and_dependency_by_id_patch = patch.object(
            ReleaseDao,
            'get_status_and_dependency_by_id',
            side_effect=self.mock_get_status_and_dependency_by_id)
        get_status_and_dependency_by_id_patch.start()
        update_by_parameters_patch = patch.object(
            ReleaseDao,
            'update_by_parameters',
            side_effect=self.mock_update_by_parameters_None)
        update_by_parameters_patch.start()

        service = ReleaseService(app_context)
        result, cost_time = service.modify_release(release_vo)
        assert result == "test_release_id"
        modify_dependency_by_release_id_patch.stop()
        get_status_and_dependency_by_id_patch.stop()
        update_by_parameters_patch.stop()
Esempio n. 3
0
    def test_new_product_release_version_success(self):
        """
        1.測試 new_release_version for product
        2.正常回傳
        """
        objectType = "product"
        request = request_data_for_new_release()
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="release_insert")
        release_vo.validate(api_type="release_insert")
        service = ReleaseService(app_context)

        check_insert_to_release_table_patch = patch.object(ReleaseDao, "insert_to_release_table",
                                                           side_effect=self.mock_insert_to_release_table)
        check_insert_to_release_table_patch.start()
        check_insert_to_mapping_table_patch = patch.object(ReleaseMappingDao, "insert_to_release_mapping_table",
                                                           side_effect=self.mock_insert_to_release_mapping_table)
        check_insert_to_mapping_table_patch.start()
        product_check_exist_patch = patch.object(ProductDao, "check_exist",
                                                side_effect=self.mock_product_check_exist)
        product_check_exist_patch.start()

        service.new_release_version(objectType, release_vo)
        check_insert_to_release_table_patch.stop()
        check_insert_to_mapping_table_patch.stop()
        product_check_exist_patch.stop()
Esempio n. 4
0
    def test_deactivate_success(self):
        """
        1.測試 deactivate
        2.update_by_parameters 正常回傳

        """
        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")

        check_parent_dependency_patch = patch.object(
            ReleaseMappingDao,
            'check_parent_dependency',
            side_effect=self.mock_check_parent_dependency_not_exist)
        check_parent_dependency_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"
        check_parent_dependency_patch.stop()
        update_by_parameters_patch.stop()
Esempio n. 5
0
def activate_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="activate")

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

    try:
        releaseVo.validate(api_type="activate")
        service = ReleaseService(app_context)
        result, cost_time = service.activate(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. 6
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)
Esempio n. 7
0
 def releaseVo_history_release_dep_info_get_running_fail(self):
     """
     1.測試releasevo api_type = history_info
     2.預期因少了get_running欄位 判斷失敗 "999900001"
     """
     request = request_data_for_history_info(fail="get_running")
     release_vo = ReleaseVo()
     release_vo.value_of_import(request, api_type="history_info")
     release_vo.validate(api_type="history_info")
Esempio n. 8
0
 def test_dependency_overview(self):
     """
     測試releasevo api_type = dependency_overview
     """
     # 只有user, 一個必填欄位 直接寫死
     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")
Esempio n. 9
0
 def releaseVo_new_release_version_fail(self):
     """
     1.測試releasevo api_type = release_insert
     2.預期因少了version欄位 判斷失敗 "999900001"
     """
     request = request_data_for_new_release(fail="version", full=True)
     release_vo = ReleaseVo()
     release_vo.value_of_import(request, api_type="release_insert")
     release_vo.validate(api_type="release_insert")
Esempio n. 10
0
 def get_spec_release_detail_fail(self):
     """
     1.測試releasevo api_type = history_info
     2.預期因少了releaseId 判斷失敗 "999900001"
     """
     request = request_data_for_get_spec_release_detail(fail="releaseId")
     release_vo = ReleaseVo()
     release_vo.value_of_import(request, api_type="get_release_info")
     release_vo.validate(api_type="get_release_info")
Esempio n. 11
0
 def test_releaseVo_history_release_dependency_information(self):
     """
     測試releasevo api_type = history_info
     """
     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")
     assert release_vo.user == request.get("user")
     assert release_vo.object_id == request.get("objectId")
     assert release_vo.get_running == request.get("getRunning")
Esempio n. 12
0
 def test_releaseVo_new_release_version(self):
     """
     測試releasevo api_type = release_insert
     """
     request = request_data_for_new_release()
     release_vo = ReleaseVo()
     release_vo.value_of_import(request, api_type="release_insert")
     release_vo.validate(api_type="release_insert")
     assert release_vo.user == request.get("user")
     assert release_vo.object_id == request.get("objectId")
     assert release_vo.version == request.get("version")
Esempio n. 13
0
    def test_get_spec_release_detail_success(self):
        """
        測試releasevo api_type = get_release_info
        """
        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")

        assert release_vo.user == request.get("user")
        assert release_vo.release_id_list == request.get("releaseId")
Esempio n. 14
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()
Esempio n. 15
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)
Esempio n. 16
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)
Esempio n. 17
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)
Esempio n. 18
0
    def ReleaseVo_modify_wrong_type_fail(self):
        """
        1.測試releaseVo api_type = modify_dependency
        2.預期request_modify_data 因 releaseId 的資料型態錯誤 判斷失敗

        Parameters
        ----------
        version_vo : object
            包含所有 input 資訊
        """
        request = request_modify_data(fail="wrong type")
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="modify_release_info")
        release_vo.validate(api_type="modify_release_info")
Esempio n. 19
0
    def ReleaseVo_verify_missing_data_fail(self):
        """
        1.測試releaseVo api_type = verify
        2.預期request_activate_data 因 object_id 的資料型態錯誤 判斷失敗

        Parameters
        ----------
        version_vo : object
            包含所有 input 資訊
        """
        request = request_verify_data(fail="missing data")
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="verify")
        release_vo.validate(api_type="verify")
Esempio n. 20
0
    def ReleaseVo_activate_fail(self):
        """
        1.測試releaseVo api_type = activate
        2.預期request_activate_data 因少releaseId欄位 判斷失敗

        Parameters
        ----------
        version_vo : object
            包含所有 input 資訊
        """
        request = request_activate_data(running_status=1, fail="release_id")
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="activate")
        release_vo.validate(api_type="activate")
Esempio n. 21
0
    def ReleaseVo_latest_info_missing_data_fail(self):
        """
        1.測試releaseVo api_type = latest_info
        2.預期request_activate_data 因缺少 user 欄位 判斷失敗

        Parameters
        ----------
        version_vo : object
            包含所有 input 資訊
        """
        request = request_latest_info_data(fail="missing data")
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="latest_info")
        release_vo.validate(api_type="latest_info")
Esempio n. 22
0
    def ReleaseVo_latest_info_wrong_type_fail(self):
        """
        1.測試releaseVo api_type = latest_info
        2.預期request_activate_data 因 object_id 的資料型態錯誤 判斷失敗

        Parameters
        ----------
        version_vo : object
            包含所有 input 資訊
        """
        request = request_latest_info_data(fail="wrong type")
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="latest_info")
        release_vo.validate(api_type="latest_info")
Esempio n. 23
0
    def ReleaseVo_modify_missing_data_fail(self):
        """
        1.測試releaseVo api_type = modify_dependency
        2.預期request_modify_data 因丟失 user 的資料 判斷失敗

        Parameters
        ----------
        version_vo : object
            包含所有 input 資訊
        """
        request = request_modify_data(fail="missing data")
        release_vo = ReleaseVo()
        release_vo.value_of_import(request, api_type="modify_release_info")
        release_vo.validate(api_type="modify_release_info")
Esempio n. 24
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()
Esempio n. 25
0
    def test_ReleaseVo_latest_info_success(self):
        """
        1.測試ReleaseVo api_type = latest_info
        2.判斷request_latest_info_data與releasevo要一致

        Parameters
        ----------
        version_vo : object
            包含所有 input 資訊
        """
        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")
        assert release_vo.user == request.get("user")
        assert release_vo.object_id == request.get("objectId")
Esempio n. 26
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()
Esempio n. 27
0
    def test_ReleaseVo_activate_success(self):
        """
        1.測試ReleaseVo api_type = activate
        2.判斷request_activate_data與releasevo要一致

        Parameters
        ----------
        version_vo : object
            包含所有 input 資訊
        """
        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")
        assert release_vo.user == request.get("user")
        assert release_vo.release_id == request.get("releaseId")
        assert release_vo.running_status == request.get("runningStatus")
Esempio n. 28
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()
Esempio n. 29
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()