How to use _get_bytes_used method in tempest

Best Python code snippet using tempest_python

test_container_quotas.py

Source:test_container_quotas.py Github

copy

Full Screen

...52 def test_upload_valid_object(self):53 """Attempts to uploads an object smaller than the bytes quota."""54 object_name = data_utils.rand_name(name="TestObject")55 data = data_utils.arbitrary_string(QUOTA_BYTES)56 nbefore = self._get_bytes_used()57 resp, _ = self.object_client.create_object(58 self.container_name, object_name, data)59 self.assertIn(int(resp['status']), HTTP_SUCCESS)60 self.assertHeaders(resp, 'Object', 'PUT')61 nafter = self._get_bytes_used()62 self.assertEqual(nbefore + len(data), nafter)63 @testtools.skipIf(not container_quotas_available, SKIP_MSG)64 @attr(type="smoke")65 def test_upload_large_object(self):66 """Attempts to upload an object lagger than the bytes quota."""67 object_name = data_utils.rand_name(name="TestObject")68 data = data_utils.arbitrary_string(QUOTA_BYTES + 1)69 nbefore = self._get_bytes_used()70 self.assertRaises(exceptions.OverLimit,71 self.object_client.create_object,72 self.container_name, object_name, data)73 nafter = self._get_bytes_used()74 self.assertEqual(nbefore, nafter)75 @testtools.skipIf(not container_quotas_available, SKIP_MSG)76 @attr(type="smoke")77 def test_upload_too_many_objects(self):78 """Attempts to upload many objects that exceeds the count limit."""79 for _ in range(QUOTA_COUNT):80 name = data_utils.rand_name(name="TestObject")81 self.object_client.create_object(self.container_name, name, "")82 nbefore = self._get_object_count()83 self.assertEqual(nbefore, QUOTA_COUNT)84 self.assertRaises(exceptions.OverLimit,85 self.object_client.create_object,86 self.container_name, "OverQuotaObject", "")87 nafter = self._get_object_count()88 self.assertEqual(nbefore, nafter)89 def _get_container_metadata(self):90 resp, _ = self.container_client.list_container_metadata(91 self.container_name)92 return resp93 def _get_object_count(self):94 resp = self._get_container_metadata()95 return int(resp["x-container-object-count"])96 def _get_bytes_used(self):97 resp = self._get_container_metadata()...

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