def getPhotoId(photoId, request): if photoId: return photoId if request: referrer = getReferrerFromRequest(request) photoId = flickrapi.getPhotoIdFromUrl(referrer) return photoId
def test_getFlickrPhotoId_None_ReturnsNone(self): """ For a None 'flickr url', returns None """ photoId = flickrapi.getPhotoIdFromUrl(None) self.assertEqual(photoId, None)
def test_getFlickrPhotoId_FlickrInvalidUrl_ReturnsNone(self): """ Given an invalid flickr URL, returns None """ photoId = flickrapi.getPhotoIdFromUrl("http://www.flickr.com/photos/mendhak") self.assertEqual(photoId, None)
def test_getFlickrPhotoId_FlickrUrlExtended_ReturnsPhotoID(self): """ Given a long Flickr URL, return the PHOTO ID """ photoId = flickrapi.getPhotoIdFromUrl("http://www.flickr.com/photos/mendhak/123456/in/photostream/lightbox/2452") self.assertEqual("123456", photoId)
def test_getFlickrPhotoId_FlickrURL_ReturnsPhotoID(self): """ Given a flickr photo page URL, return the Photo ID """ photoId = flickrapi.getPhotoIdFromUrl("http://flickr.com/photos/mendhak/12345") self.assertEqual("12345", photoId)