def test_get_pod_annotation_failure(self): # NOTE: this method currently returns None in case of failure. No info # about the failure is returned. This might change in the future. with mock.patch('requests.get') as req_mock: req_mock.return_value = MockResponse("Error", status_code=404) ann = kubernetes.get_pod_annotations('http://meh:8080', 'meh_ns', 'meh_pod') self._verify_mock_call( req_mock, 'http://meh:8080/api/v1/namespaces/meh_ns/pods/meh_pod', headers=self.exp_headers) self.assertIsNone(ann)
def _test_get_pod_annotations(self, annotations): if annotations: ann_data = {'annotations': annotations} else: ann_data = annotations with mock.patch('requests.get') as req_mock: req_mock.return_value = MockResponse( '{"metadata": %s}' % json.dumps(ann_data or {})) ann = kubernetes.get_pod_annotations('http://meh:8080', 'meh_ns', 'meh_pod') self._verify_mock_call( req_mock, 'http://meh:8080/api/v1/namespaces/meh_ns/pods/meh_pod', headers=self.exp_headers) self.assertEqual(annotations, ann)