How to use the pythonping.executor.SuccessOn.One function in pythonping

To help you get started, we’ve selected a few pythonping examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alessandromaggio / pythonping / test / test_executor.py View on Github external
def test_success_all_success(self):
        """Verify success is calculated correctly if all responses are successful"""
        rs = executor.ResponseList([
            SuccessfulResponseMock(None, 1),
            SuccessfulResponseMock(None, 1),
            SuccessfulResponseMock(None, 1),
            SuccessfulResponseMock(None, 1)
        ])
        self.assertTrue(
            rs.success(executor.SuccessOn.One),
            'Unable to calculate success on one correctly with all responses successful'
        )
        self.assertTrue(
            rs.success(executor.SuccessOn.Most),
            'Unable to calculate success on most with all responses successful'
        )
        self.assertTrue(
            rs.success(executor.SuccessOn.All),
            'Unable to calculate success on all with all responses successful'
        )
github alessandromaggio / pythonping / pythonping / executor.py View on Github external
    def success(self, option=SuccessOn.One):
        """Check success state of the request.

        :param option: Sets a threshold for success sign. ( 1 - SuccessOn.One, 2 - SuccessOn.Most, 3 - SuccessOn.All )
        :type option: int
        :return: Whether this set of responses is successful
        :rtype: bool
        """
        result = False
        success_list = [resp.success for resp in self._responses]
        if option == SuccessOn.One:
            result = True in success_list
        elif option == SuccessOn.Most:
            result = success_list.count(True) / len(success_list) > 0.5
        elif option == SuccessOn.All:
            result = False not in success_list
        return result
github alessandromaggio / pythonping / pythonping / executor.py View on Github external
def success(self, option=SuccessOn.One):
        """Check success state of the request.

        :param option: Sets a threshold for success sign. ( 1 - SuccessOn.One, 2 - SuccessOn.Most, 3 - SuccessOn.All )
        :type option: int
        :return: Whether this set of responses is successful
        :rtype: bool
        """
        result = False
        success_list = [resp.success for resp in self._responses]
        if option == SuccessOn.One:
            result = True in success_list
        elif option == SuccessOn.Most:
            result = success_list.count(True) / len(success_list) > 0.5
        elif option == SuccessOn.All:
            result = False not in success_list
        return result