Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions vision/google/cloud/vision/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ def from_api_repr(cls, response):
:rtype: :class:`~google.cloud.vision.annotations.Annotations`
:returns: An instance of ``Annotations`` with detection types loaded.
"""
for feature_type in response.keys():

This comment was marked as spam.

This comment was marked as spam.

if feature_type not in _KEY_MAP:
del response[feature_type]
annotations = {
_KEY_MAP[feature_type]: _entity_from_response_type(
feature_type, annotation)
Expand Down
9 changes: 9 additions & 0 deletions vision/unit_tests/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ def test_ctor(self):
self.assertEqual(annotations.safe_searches, [True])
self.assertEqual(annotations.texts, [True])

def test_unsupported_http_annotation(self):
returned = {
'responses': [
{'someMadeUpAnnotation': None},
],
}
annotation = self._get_target_class().from_api_repr(returned)
self.assertIsInstance(annotation, self._get_target_class())

def test_from_pb(self):
from google.cloud.vision.likelihood import Likelihood
from google.cloud.vision.safe_search import SafeSearchAnnotation
Expand Down