Exemplo n.º 1
0
def test_delete_throws():
    with patch('requests.delete') as patched_delete:
        type(patched_delete.return_value).status_code = 500

        client = ReliableHttpClient(endpoint, {}, retry_policy)

        client.delete("r", [200])
Exemplo n.º 2
0
def test_delete_throws():
    with patch('requests.delete') as patched_delete:
        type(patched_delete.return_value).status_code = 500

        client = ReliableHttpClient(endpoint, {}, retry_policy)

        client.delete("r", [200])
def test_delete_throws():
    with patch('requests.delete') as patched_delete:
        type(patched_delete.return_value).status_code = 500

        client = ReliableHttpClient("http://url.com", {}, "username", "password", retry_policy)

        client.delete("r", [200])
Exemplo n.º 4
0
def test_delete_throws():
    with patch('requests.delete') as patched_delete:
        type(patched_delete.return_value).status_code = 500

        client = ReliableHttpClient("http://url.com", {}, "username", "password", retry_policy)

        client.delete("r", [200])
Exemplo n.º 5
0
def test_delete():
    with patch('requests.delete') as patched_delete:
        type(patched_delete.return_value).status_code = 200

        client = ReliableHttpClient(endpoint, {}, retry_policy)

        result = client.delete("r", [200])

        assert_equals(200, result.status_code)
Exemplo n.º 6
0
def test_delete():
    with patch('requests.delete') as patched_delete:
        type(patched_delete.return_value).status_code = 200

        client = ReliableHttpClient(endpoint, {}, retry_policy)

        result = client.delete("r", [200])

        assert_equals(200, result.status_code)
def test_delete():
    with patch('requests.delete') as patched_delete:
        type(patched_delete.return_value).status_code = 200

        client = ReliableHttpClient("http://url.com", {}, "username", "password", retry_policy)

        result = client.delete("r", [200])

        assert_equals(200, result.status_code)
Exemplo n.º 8
0
def test_delete():
    with patch('requests.delete') as patched_delete:
        type(patched_delete.return_value).status_code = 200

        client = ReliableHttpClient("http://url.com", {}, "username", "password", retry_policy)

        result = client.delete("r", [200])

        assert_equals(200, result.status_code)
Exemplo n.º 9
0
def test_delete_will_retry():
    global sequential_values, retry_policy
    retry_policy = MagicMock()
    retry_policy.should_retry.return_value = True
    retry_policy.seconds_to_sleep.return_value = 0.01

    with patch('requests.delete') as patched_delete:
        # When we call assert_equals in this unit test, the side_effect is executed.
        # So, the last status_code should be repeated.
        sequential_values = [500, 200, 200]
        pm = PropertyMock()
        pm.side_effect = return_sequential
        type(patched_delete.return_value).status_code = pm
        client = ReliableHttpClient(endpoint, {}, retry_policy)

        result = client.delete("r", [200])

        assert_equals(200, result.status_code)
        retry_policy.should_retry.assert_called_once_with(500, False, 0)
        retry_policy.seconds_to_sleep.assert_called_once_with(0)
Exemplo n.º 10
0
def test_delete_will_retry():
    global sequential_values, retry_policy
    retry_policy = MagicMock()
    retry_policy.should_retry.return_value = True
    retry_policy.seconds_to_sleep.return_value = 0.01

    with patch('requests.delete') as patched_delete:
        # When we call assert_equals in this unit test, the side_effect is executed.
        # So, the last status_code should be repeated.
        sequential_values = [500, 200, 200]
        pm = PropertyMock()
        pm.side_effect = return_sequential
        type(patched_delete.return_value).status_code = pm
        client = ReliableHttpClient(endpoint, {}, retry_policy)

        result = client.delete("r", [200])

        assert_equals(200, result.status_code)
        retry_policy.should_retry.assert_called_once_with(500, False, 0)
        retry_policy.seconds_to_sleep.assert_called_once_with(0)