def test_get_url_shortener(self): us_settings.URL_SHORTENER_BACKEND = 'mymodule.myclass' try: with warnings.catch_warnings(record=True) as w: self.assertEquals(get_url_shortener(), default_backend) self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) self.assertEquals( str(w[-1].message), 'mymodule.myclass backend cannot be imported') except AttributeError: # Fail under Python2.5, because of'warnings.catch_warnings' pass us_settings.URL_SHORTENER_BACKEND = 'zinnia.tests.custom_url_shortener' try: with warnings.catch_warnings(record=True) as w: self.assertEquals(get_url_shortener(), default_backend) self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) self.assertEquals( str(w[-1].message), 'This backend only exists for testing') except AttributeError: # Fail under Python2.5, because of'warnings.catch_warnings' pass us_settings.URL_SHORTENER_BACKEND = 'zinnia.url_shortener'\ '.backends.default' self.assertEquals(get_url_shortener(), default_backend)
def test_get_url_shortener(self): us_settings.URL_SHORTENER_BACKEND = 'mymodule.myclass' try: with warnings.catch_warnings(record=True) as w: self.assertEquals(get_url_shortener(), default_backend) self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) self.assertEquals( str(w[-1].message), 'mymodule.myclass backend cannot be imported') except AttributeError: # Fail under Python2.5, because of'warnings.catch_warnings' pass us_settings.URL_SHORTENER_BACKEND = 'zinnia.tests.custom_url_shortener' try: with warnings.catch_warnings(record=True) as w: self.assertEquals(get_url_shortener(), default_backend) self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) self.assertEquals(str(w[-1].message), 'This backend only exists for testing') except AttributeError: # Fail under Python2.5, because of'warnings.catch_warnings' pass us_settings.URL_SHORTENER_BACKEND = 'zinnia.url_shortener'\ '.backends.default' self.assertEquals(get_url_shortener(), default_backend)
def test_get_url_shortener(self): us_settings.URL_SHORTENER_BACKEND = "mymodule.myclass" with warnings.catch_warnings(record=True) as w: self.assertEqual(get_url_shortener(), default_backend) self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) self.assertEqual(str(w[-1].message), "mymodule.myclass backend cannot be imported") us_settings.URL_SHORTENER_BACKEND = "zinnia.tests.implementations." "custom_url_shortener" with warnings.catch_warnings(record=True) as w: self.assertEqual(get_url_shortener(), default_backend) self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) self.assertEqual(str(w[-1].message), "This backend only exists for testing") us_settings.URL_SHORTENER_BACKEND = "zinnia.url_shortener" ".backends.default" self.assertEqual(get_url_shortener(), default_backend)
def test_get_url_shortener(self): us_settings.URL_SHORTENER_BACKEND = 'mymodule.myclass' with warnings.catch_warnings(record=True) as w: self.assertEquals(get_url_shortener(), default_backend) self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) self.assertEquals(str(w[-1].message), 'mymodule.myclass backend cannot be imported') us_settings.URL_SHORTENER_BACKEND = 'zinnia.tests.custom_url_shortener' with warnings.catch_warnings(record=True) as w: self.assertEquals(get_url_shortener(), default_backend) self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) self.assertEquals(str(w[-1].message), 'This backend only exists for testing') us_settings.URL_SHORTENER_BACKEND = 'zinnia.url_shortener'\ '.backends.default' self.assertEquals(get_url_shortener(), default_backend)
def test_get_url_shortener(self): us_settings.URL_SHORTENER_BACKEND = 'mymodule.myclass' with warnings.catch_warnings(record=True) as w: self.assertEquals(get_url_shortener(), default_backend) self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) self.assertEquals( str(w[-1].message), 'mymodule.myclass backend cannot be imported') us_settings.URL_SHORTENER_BACKEND = 'zinnia.tests.custom_url_shortener' with warnings.catch_warnings(record=True) as w: self.assertEquals(get_url_shortener(), default_backend) self.assertTrue(issubclass(w[-1].category, RuntimeWarning)) self.assertEquals( str(w[-1].message), 'This backend only exists for testing') us_settings.URL_SHORTENER_BACKEND = 'zinnia.url_shortener'\ '.backends.default' self.assertEquals(get_url_shortener(), default_backend)
def short_url(self): """Return the entry's short url""" return get_url_shortener()(self)
def short_url(self): """ Returns the entry's short url. """ return get_url_shortener()(self)