How to use create_object_continue method in tempest

Best Python code snippet using tempest_python

test_object_client.py

Source:test_object_client.py Github

copy

Full Screen

...25 self.object_client = object_client.ObjectClient(self.fake_auth,26 'swift', 'region1')27 @mock.patch.object(object_client, 'create_connection')28 def test_create_object_continue_no_data(self, mock_poc):29 self._validate_create_object_continue(None, mock_poc)30 @mock.patch.object(object_client, 'create_connection')31 def test_create_object_continue_with_data(self, mock_poc):32 self._validate_create_object_continue('hello', mock_poc)33 @mock.patch.object(object_client, 'create_connection')34 def test_create_continue_with_no_continue_received(self, mock_poc):35 self._validate_create_object_continue('hello', mock_poc,36 initial_status=201)37 def _validate_create_object_continue(self, req_data,38 mock_poc, initial_status=100):39 expected_hdrs = {40 'X-Auth-Token': self.fake_auth.get_token(),41 'content-length': 0 if req_data is None else len(req_data),42 'Expect': '100-continue'}43 # Setup the Mocks prior to invoking the object creation44 mock_resp_cls = mock.Mock()45 mock_resp_cls._read_status.return_value = ("1", initial_status, "OK")46 mock_poc.return_value.response_class.return_value = mock_resp_cls47 # This is the final expected return value48 mock_poc.return_value.getresponse.return_value.status = 20149 mock_poc.return_value.getresponse.return_value.reason = 'OK'50 # Call method to PUT object using expect:100-continue51 cnt = "container1"52 obj = "object1"53 path = "/%s/%s" % (cnt, obj)54 # If the expected initial status is not 100, then an exception55 # should be thrown and the connection closed56 if initial_status is 100:57 status, reason = \58 self.object_client.create_object_continue(cnt, obj, req_data)59 else:60 self.assertRaises(exceptions.UnexpectedResponseCode,61 self.object_client.create_object_continue, cnt,62 obj, req_data)63 mock_poc.return_value.close.assert_called_once_with()64 # Verify that putrequest is called 1 time with the appropriate values65 mock_poc.return_value.putrequest.assert_called_once_with('PUT', path)66 # Verify that headers were written, including "Expect:100-continue"67 calls = []68 for header, value in expected_hdrs.items():69 calls.append(mock.call(header, value))70 mock_poc.return_value.putheader.assert_has_calls(calls, False)71 mock_poc.return_value.endheaders.assert_called_once_with()72 # The following steps are only taken if the initial status is 100...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful