def test_long_running_delete(self): # Test polling from azure-asyncoperation header response = TestArmPolling.mock_send( 'DELETE', 202, {'azure-asyncoperation': ASYNC_URL}, body="") poll = LROPoller(CLIENT, response, TestArmPolling.mock_outputs, ARMPolling(0)) poll.wait() assert poll._polling_method._pipeline_response.http_response.internal_response.randomFieldFromPollAsyncOpHeader is None
def test_long_running_delete(self): # Test polling from operation-location header response = TestBasePolling.mock_send('DELETE', 202, {'operation-location': ASYNC_URL}, body="") poll = LROPoller(CLIENT, response, TestBasePolling.mock_deserialization_no_body, LROBasePolling(0)) poll.wait() assert poll._polling_method._pipeline_response.http_response.internal_response.randomFieldFromPollAsyncOpHeader is None
def test_long_running_post_legacy(self): # Former oooooold tests to refactor one day to something more readble # Test polling from azure-asyncoperation header response = TestArmPolling.mock_send( 'POST', 201, {'azure-asyncoperation': ASYNC_URL}, body={'properties':{'provisioningState': 'Succeeded'}}) poll = LROPoller(CLIENT, response, TestArmPolling.mock_deserialization_no_body, ARMPolling(0)) poll.wait() assert poll._polling_method._pipeline_response.http_response.internal_response.randomFieldFromPollAsyncOpHeader is None # Test polling from azure-asyncoperation header response = TestArmPolling.mock_send( 'POST', 202, {'azure-asyncoperation': ASYNC_URL}, body={'properties':{'provisioningState': 'Succeeded'}}) poll = LROPoller(CLIENT, response, TestArmPolling.mock_deserialization_no_body, ARMPolling(0)) poll.wait() assert poll._polling_method._pipeline_response.http_response.internal_response.randomFieldFromPollAsyncOpHeader is None # Test polling from location header response = TestArmPolling.mock_send( 'POST', 202, {'location': LOCATION_URL}, body={'properties':{'provisioningState': 'Succeeded'}}) poll = LROPoller(CLIENT, response, TestArmPolling.mock_outputs, ARMPolling(0)) assert poll.result().name == TEST_NAME assert poll._polling_method._pipeline_response.http_response.internal_response.randomFieldFromPollLocationHeader is None # Test fail to poll from azure-asyncoperation header response = TestArmPolling.mock_send( 'POST', 202, {'azure-asyncoperation': ERROR}) with pytest.raises(BadEndpointError): poll = LROPoller(CLIENT, response, TestArmPolling.mock_outputs, ARMPolling(0)).result() # Test fail to poll from location header response = TestArmPolling.mock_send( 'POST', 202, {'location': ERROR}) with pytest.raises(BadEndpointError): poll = LROPoller(CLIENT, response, TestArmPolling.mock_outputs, ARMPolling(0)).result()
def test_long_running_negative(self): global LOCATION_BODY global POLLING_STATUS # Test LRO PUT throws for invalid json LOCATION_BODY = '{' response = TestArmPolling.mock_send('POST', 202, {'location': LOCATION_URL}) poll = LROPoller(CLIENT, response, TestArmPolling.mock_outputs, ARMPolling(0)) with pytest.raises(DecodeError): poll.wait() LOCATION_BODY = '{\'"}' response = TestArmPolling.mock_send('POST', 202, {'location': LOCATION_URL}) poll = LROPoller(CLIENT, response, TestArmPolling.mock_outputs, ARMPolling(0)) with pytest.raises(DecodeError): poll.wait() LOCATION_BODY = '{' POLLING_STATUS = 203 response = TestArmPolling.mock_send('POST', 202, {'location': LOCATION_URL}) poll = LROPoller(CLIENT, response, TestArmPolling.mock_outputs, ARMPolling(0)) with pytest.raises( HttpResponseError): # TODO: Node.js raises on deserialization poll.wait() LOCATION_BODY = json.dumps({'name': TEST_NAME}) POLLING_STATUS = 200