def openmsg(self, msg): msg = goo_gl.shorten_long_urls(msg, api_key=_ICBHEAD_URL_SHORTENER_API_KEY, include_note=True) encoded_messages = self._wrap_and_encode(msg, self.MAX_LINE) for encoded_msg in encoded_messages: self.send([self.M_OPENMSG, encoded_msg])
def test_shorten_long_urls(self): new_text = goo_gl.shorten_long_urls(self._text, 26) self.assertLess(len(new_text), len(self._text)) self.assertIn('http://goo.gl/shorter', new_text) for long_url, fake_short_url, _ in self._test_url_info: self.assertIn(long_url, self._text) self.assertNotIn(long_url, new_text) self.assertIn(fake_short_url, new_text)
def test_shorten_long_urls_with_note(self): new_text = goo_gl.shorten_long_urls(self._text, 26, include_note=True) self.assertIn('http://goo.gl/shorter', new_text) for long_url, fake_short_url, url_note in self._test_url_info: self.assertIn(long_url, self._text) self.assertNotIn(url_note, self._text) self.assertNotIn(long_url, new_text) self.assertIn(url_note, new_text) self.assertIn(fake_short_url, new_text)