Esempio n. 1
0
    def test_no_request_timeout_in_config(self, mocked_prepare, mocked_send):
        """
            Verify that if request_timeout is not provided in config then default value is used
        """
        jira_client = Client({"base_url": "https://your-jira-domain"}) # No request_timeout in config
        jira_client.refresh_token = "test"

        # Call request method which call Session.send with timeout
        jira_client.request("test", method="GET", path="http://test")

        # Verify Session.send is called with expected timeout
        args, kwargs = mocked_send.call_args
        self.assertEqual(kwargs.get('timeout'), 300) # Verify timeout argument
Esempio n. 2
0
    def test_request_timeout_backoff(
        self, mocked_prepare, mocked_send, mocked_sleep, mocked_test):
        """
            Verify request function is backoff for 6 times on Timeout exception
        """
        jira_client = Client({"base_url": "https://your-jira-domain"})
        jira_client.refresh_token = "test"

        try:
            jira_client.request("test", method="GET", path="http://test")
        except requests.exceptions.Timeout:
            pass

        # Verify that Session.send is called 6 times
        self.assertEqual(mocked_send.call_count, 6)
Esempio n. 3
0
    def test_string_request_timeout_in_config(self, mocked_prepare, mocked_send):
        """
            Verify that if request_timeout is provided in config (string value) then it should be use
        """
        jira_client = Client({
            "base_url": "https://your-jira-domain",
            "request_timeout": "100" # string format timeout in config
            })
        jira_client.refresh_token = "test"

        # Call request method which call Session.send with timeout
        jira_client.request("test", method="GET", path="http://test")

        # Verify requests.request and Session.send is called with expected timeout
        args, kwargs = mocked_send.call_args
        self.assertEqual(kwargs.get('timeout'), 100) # Verify timeout argument