Example #1
0
    def test_async_retry_decorating_at_function_with_default_raising_exception(
            self, async_strategy: AsynchronousStrategy):
        init_flag()

        async_strategy.run(
            function=async_target_function_raising_exception_with_default)
        _result = async_strategy.get_result()

        _result_content = [_r.data for _r in _result]
        _result_exception_content = [_r.exception for _r in _result]

        _result_content_set = set(_result_content)
        _result_exception_content_set = set(_result_exception_content)

        assert len(_result_content_set
                   ) == 1 and list(_result_content_set)[0] is None, f""
        assert len(_result_exception_content_set) == 1 and list(
            _result_exception_content_set)[0] is _Test_Exception, f""

        _process_flag = get_process_flag()

        assert _process_flag.Running_Target_Function_Counter == _Default_Value * _Worker_Size, F"The running counter flag should be '{_Default_Value}'"
        assert _process_flag.Initial_Handling_Flag_Counter == 0, "The initial handling flag should be '0'."
        assert _process_flag.Done_Handling_Flag_Counter == 0, "The done handling flag should be '0'"
        assert _process_flag.Final_Handling_Flag_Counter == 0, "The final handling flag should be '0'"
        assert _process_flag.Error_Handling_Flag_Counter == 0, "The error handling flag should be '0'"
Example #2
0
    def test_async_retry_decorating_at_bounded_function_raising_exception(self, async_strategy: AsynchronousStrategy, target_bounded_async_function: TargetBoundedAsyncFunction):
        init_flag()

        async_strategy.run(function=target_bounded_async_function.target_method_raising_exception)

        _process_flag = get_process_flag()

        assert _process_flag.Running_Target_Function_Counter == _Retry_Time * _Worker_Size, f"The running counter flag should be '{_Worker_Size}'."
        assert _process_flag.Initial_Handling_Flag_Counter == _Retry_Time * _Worker_Size, f"The count of initial handling flag should be '{_Retry_Time * _Worker_Size}'."
        assert _process_flag.Done_Handling_Flag_Counter == 0, "The count of done handling flag should be 'False'"
        assert _process_flag.Final_Handling_Flag_Counter == _Retry_Time * _Worker_Size, f"The count of final handling flag should be '{_Retry_Time * _Worker_Size}'"
        assert _process_flag.Error_Handling_Flag_Counter == _Retry_Time * _Worker_Size, f"The count of error handling flag should be '{_Retry_Time * _Worker_Size}'"
Example #3
0
    def test_async_retry_decorating_at_function_raising_exception(self, async_strategy: AsynchronousStrategy):
        init_flag()

        async_strategy.run(function=async_target_function_raising_exception)

        _process_flag = get_process_flag()

        assert _process_flag.Running_Target_Function_Counter == _Retry_Time * _Worker_Size, f"The running counter flag should be '{_Retry_Time}'"
        assert _process_flag.Initial_Handling_Flag_Counter == _Retry_Time * _Worker_Size, f"The initial handling flag should be '{_Retry_Time}'."
        assert _process_flag.Done_Handling_Flag_Counter == 0, "The done handling flag should be '0'"
        assert _process_flag.Final_Handling_Flag_Counter == _Retry_Time * _Worker_Size, f"The final handling flag should be '{_Retry_Time}'"
        assert _process_flag.Error_Handling_Flag_Counter == _Retry_Time * _Worker_Size, f"The error handling flag should be '{_Retry_Time}'"
Example #4
0
    def test_async_retry_decorating_at_function_with_default(self, async_strategy: AsynchronousStrategy):
        init_flag()

        async_strategy.run(function=async_target_function_with_default)
        _process_flag = get_process_flag()

        assert _process_flag.Running_Target_Function_Counter == _Default_Value * _Worker_Size, f"The running counter flag should be '{_Default_Value}'"
        assert _process_flag.Initial_Handling_Flag_Counter == 0, "The initial handling flag should be '0'."
        assert _process_flag.Done_Handling_Flag_Counter == 0, "The done handling flag should be '0'"
        assert _process_flag.Final_Handling_Flag_Counter == 0, "The final handling flag should be '0'"
        assert _process_flag.Error_Handling_Flag_Counter == 0, "The error handling flag should be '0'"

        _result = async_strategy.get_result()
        _result_content = [_r.data for _r in _result]
        _result_content_one_list = list(set(_result_content))

        assert len(_result_content_one_list) == 1 and _result_content_one_list[0] == _Test_Return_Value, f"The return value should be the same as '{_Test_Return_Value}'."