def test_retrieve_fails_with_different_content_type(self, mock_get_method): """ tests that the retrieve method fails when the response is for a media type that is not supported. """ headers = {'content-type': 'different/not-supported'} _setup_mock_response_for_retriever( mock_get_method, self._public_key_pem, headers) retriever = HTTPSPublicKeyRetriever(self.base_url) with self.assertRaises(ValueError): retriever.retrieve('example/eg')
def test_retrieve(self, mock_get_method): """ tests that the retrieve method works expected. """ _setup_mock_response_for_retriever( mock_get_method, self._public_key_pem) retriever = HTTPSPublicKeyRetriever(self.base_url) self.assertEqual( retriever.retrieve('example/eg'), self._public_key_pem)
def test_retrieve_with_charset_in_content_type_h(self, mock_get_method): """ tests that the retrieve method works expected when there is a charset in the response content-type header. """ headers = {'content-type': 'application/x-pem-file;charset=UTF-8'} _setup_mock_response_for_retriever( mock_get_method, self._public_key_pem, headers) retriever = HTTPSPublicKeyRetriever(self.base_url) self.assertEqual( retriever.retrieve('example/eg'), self._public_key_pem)