コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
    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)
コード例 #6
0
 def short_url(self):
     """Return the entry's short url"""
     return get_url_shortener()(self)
コード例 #7
0
ファイル: entry.py プロジェクト: stefanw/django-blog-zinnia
 def short_url(self):
     """
     Returns the entry's short url.
     """
     return get_url_shortener()(self)