def test_write_qr_image(self): service = Googl() service.write_qr_image(self.test_short_url, self.qr_image_path) self.assertEqual('png', imghdr.what(self.qr_image_path))
def test_expand_url_without_key(self): service = Googl() generated_long_url = service.expand_url(self.test_short_url) self.assertEqual(self.test_long_url, generated_long_url)
(options, args) = parser.parse_args() # Validate the service that the user specified. If nothing is specified, we # default to goo.gl if options.service: if options.service not in SUPPORTED_SERVICES: print 'Unsupported service %s. Supported services are %s.' \ %(options.service, ', '.join(SUPPORTED_SERVICES)) sys.exit(-1) else: options.service = 'goo.gl' # Now, instantiate the service object based upon user preference. service = None if 'goo.gl' == options.service: service = Googl(options.svc_api_key) elif 'bit.ly' == options.service: # bit.ly requires a login account and api key. if not options.login or not options.svc_api_key: print 'bit.ly requires a valid account and API key.' sys.exit(-1) service = Bitly(options.login, options.svc_api_key) if 'git.io' == options.service: service = Gitio() elif 'tinyurl.com' == options.service: service = TinyUrlcom() elif 'v.gd' == options.service: service = Vgd() elif 'is.gd' == options.service: service = Isgd()
def test_shorten_url_with_key(self): service = Googl(api_key=self.api_key) generated_short_url = service.shorten_url(self.test_long_url) self.assertEqual(self.test_short_url, generated_short_url)
def shorten_link(self, link): shortener = Googl() return shortener.shorten_url(link)