Best Python code snippet using tempest_python
test_rest_client.py
Source:test_rest_client.py
...66 self.assertRaises(exceptions.NotFound, self.rest_client.post,67 self.url, {}, {})68class TestRestClientHeadersJSON(TestRestClientHTTPMethods):69 TYPE = "json"70 def _verify_headers(self, resp):71 self.assertEqual(self.rest_client._get_type(), self.TYPE)72 resp = dict((k.lower(), v) for k, v in six.iteritems(resp))73 self.assertEqual(self.header_value, resp['accept'])74 self.assertEqual(self.header_value, resp['content-type'])75 def setUp(self):76 super(TestRestClientHeadersJSON, self).setUp()77 self.rest_client.TYPE = self.TYPE78 self.header_value = 'application/%s' % self.rest_client._get_type()79 def test_post(self):80 resp, __ = self.rest_client.post(self.url, {})81 self._verify_headers(resp)82 def test_get(self):83 resp, __ = self.rest_client.get(self.url)84 self._verify_headers(resp)85 def test_delete(self):86 resp, __ = self.rest_client.delete(self.url)87 self._verify_headers(resp)88 def test_patch(self):89 resp, __ = self.rest_client.patch(self.url, {})90 self._verify_headers(resp)91 def test_put(self):92 resp, __ = self.rest_client.put(self.url, {})93 self._verify_headers(resp)94 def test_head(self):95 self.useFixture(mockpatch.PatchObject(self.rest_client,96 'response_checker'))97 resp, __ = self.rest_client.head(self.url)98 self._verify_headers(resp)99 def test_copy(self):100 resp, __ = self.rest_client.copy(self.url)101 self._verify_headers(resp)102class TestRestClientUpdateHeaders(BaseRestClientTestClass):103 def setUp(self):104 self.fake_http = fake_http.fake_httplib2()105 super(TestRestClientUpdateHeaders, self).setUp()106 self.useFixture(mockpatch.PatchObject(self.rest_client,107 '_error_checker'))108 self.headers = {'X-Configuration-Session': 'session_id'}109 def test_post_update_headers(self):110 __, return_dict = self.rest_client.post(self.url, {},111 extra_headers=True,112 headers=self.headers)113 self.assertDictContainsSubset(114 {'X-Configuration-Session': 'session_id',115 'Content-Type': 'application/json',...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!