Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_request(self, postprocess):
sess = pdpyras.APISession('12345')
parent = Session()
request = MagicMock()
# Expected headers:
headers_get = {
'Accept': 'application/vnd.pagerduty+json;version=2',
'Authorization': 'Token token=12345',
'User-Agent': 'pdpyras/%s python-requests/%s Python/%d.%d'%(
pdpyras.__version__,
requests.__version__,
sys.version_info.major,
sys.version_info.minor
),
}
# Check default headers:
self.assertDictContainsSubset(headers_get, sess.prepare_headers('GET'))
headers_get.update(sess.prepare_headers('GET'))
# When submitting post/put, the content type should also be set
headers_post = headers_get.copy()
headers_post.update({'Content-Type': 'application/json'})
parent.headers = headers_get
with patch.object(sess, 'parent', new=parent):
parent.request = request
# Test bad request method