@@ -114,6 +114,44 @@ def test_face_detection_from_content(self):
114114 image_request ['image' ]['content' ])
115115 self .assertEqual (5 , image_request ['features' ][0 ]['maxResults' ])
116116
117+ def test_landmark_detection_from_source (self ):
118+ from google .cloud .vision .entity import EntityAnnotation
119+ from unit_tests .vision ._fixtures import (LANDMARK_DETECTION_RESPONSE as
120+ RETURNED )
121+ credentials = _Credentials ()
122+ client = self ._makeOne (project = self .PROJECT , credentials = credentials )
123+ client .connection = _Connection (RETURNED )
124+
125+ image = client .image (source_uri = _IMAGE_SOURCE )
126+ landmarks = image .detect_landmarks (limit = 3 )
127+ self .assertEqual (2 , len (landmarks ))
128+ self .assertTrue (isinstance (landmarks [0 ], EntityAnnotation ))
129+ image_request = client .connection ._requested [0 ]['data' ]['requests' ][0 ]
130+ self .assertEqual (_IMAGE_SOURCE ,
131+ image_request ['image' ]['source' ]['gcs_image_uri' ])
132+ self .assertEqual (3 , image_request ['features' ][0 ]['maxResults' ])
133+ self .assertEqual (48.861013 , landmarks [0 ].locations [0 ].latitude )
134+ self .assertEqual (2.335818 , landmarks [0 ].locations [0 ].longitude )
135+ self .assertEqual ('/m/04gdr' , landmarks [0 ].mid )
136+ self .assertEqual ('/m/094llg' , landmarks [1 ].mid )
137+
138+ def test_landmark_detection_from_content (self ):
139+ from google .cloud .vision .entity import EntityAnnotation
140+ from unit_tests .vision ._fixtures import (LANDMARK_DETECTION_RESPONSE as
141+ RETURNED )
142+ credentials = _Credentials ()
143+ client = self ._makeOne (project = self .PROJECT , credentials = credentials )
144+ client .connection = _Connection (RETURNED )
145+
146+ image = client .image (content = _IMAGE_CONTENT )
147+ landmarks = image .detect_landmarks (limit = 5 )
148+ self .assertEqual (2 , len (landmarks ))
149+ self .assertTrue (isinstance (landmarks [0 ], EntityAnnotation ))
150+ image_request = client .connection ._requested [0 ]['data' ]['requests' ][0 ]
151+ self .assertEqual (self .B64_IMAGE_CONTENT ,
152+ image_request ['image' ]['content' ])
153+ self .assertEqual (5 , image_request ['features' ][0 ]['maxResults' ])
154+
117155 def test_logo_detection_from_source (self ):
118156 from google .cloud .vision .entity import EntityAnnotation
119157 from unit_tests .vision ._fixtures import LOGO_DETECTION_RESPONSE
0 commit comments