Ejemplo n.º 1
0
 def test_zinnia_entry_shortlink(self):
     with self.assertNumQueries(1):
         response = self.client.get('/%s/' % base36(self.first_entry.pk))
     self.assertEqual(response.status_code, 301)
     self.assertEqual(
         response['Location'],
         'http://testserver%s' % self.first_entry.get_absolute_url())
Ejemplo n.º 2
0
 def test_zinnia_entry_shortlink(self):
     with self.assertNumQueries(1):
         response = self.client.get('/%s/' % base36(self.first_entry.pk))
     self.assertEqual(response.status_code, 301)
     self.assertEqual(
         response['Location'],
         self.first_entry.get_absolute_url())
Ejemplo n.º 3
0
 def test_zinnia_entry_shortlink_unpublished(self):
     """
     https://github.com/Fantomas42/django-blog-zinnia/pull/367
     """
     self.first_entry.sites.clear()
     with self.assertNumQueries(1):
         response = self.client.get('/%s/' % base36(self.first_entry.pk))
     self.assertEqual(response.status_code, 404)
Ejemplo n.º 4
0
 def test_short_url(self):
     original_shortener = shortener_settings.URL_SHORTENER_BACKEND
     shortener_settings.URL_SHORTENER_BACKEND = 'zinnia.url_shortener.'\
                                                'backends.default'
     self.assertEqual(
         self.entry.short_url, 'http://example.com' +
         reverse('zinnia:entry_shortlink', args=[base36(self.entry.pk)]))
     shortener_settings.URL_SHORTENER_BACKEND = original_shortener
Ejemplo n.º 5
0
 def test_get_short_url(self):
     self.check_with_rich_and_poor_urls(
         self.admin.get_short_url, (self.entry, ),
         '<a href="http://example.com/%(hash)s/" target="blank">'
         'http://example.com/%(hash)s/</a>' %
         {'hash': base36(self.entry.pk)},
         '<a href="%(url)s" target="blank">%(url)s</a>' %
         {'url': self.entry.get_absolute_url()})
Ejemplo n.º 6
0
 def test_zinnia_entry_shortlink_unpublished(self):
     """
     https://github.com/Fantomas42/django-blog-zinnia/pull/367
     """
     self.first_entry.sites.clear()
     with self.assertNumQueries(1):
         response = self.client.get('/%s/' % base36(self.first_entry.pk))
     self.assertEqual(response.status_code, 404)
Ejemplo n.º 7
0
 def test_get_short_url(self):
     self.check_with_rich_and_poor_urls(
         self.admin.get_short_url, (self.entry,),
         '<a href="http://example.com/%(hash)s/" target="blank">'
         'http://example.com/%(hash)s/</a>' % {
             'hash': base36(self.entry.pk)},
         '<a href="%(url)s" target="blank">%(url)s</a>' % {
             'url': self.entry.get_absolute_url()})
Ejemplo n.º 8
0
 def test_short_url(self):
     original_shortener = shortener_settings.URL_SHORTENER_BACKEND
     shortener_settings.URL_SHORTENER_BACKEND = 'zinnia.url_shortener.'\
                                                'backends.default'
     self.assertEqual(self.entry.short_url,
                      'http://example.com' +
                      reverse('zinnia:entry_shortlink',
                              args=[base36(self.entry.pk)]))
     shortener_settings.URL_SHORTENER_BACKEND = original_shortener
Ejemplo n.º 9
0
    def test_get_short_url(self):
        with self.settings(ROOT_URLCONF=self.poor_urls):
            entry_url = self.entry.get_absolute_url()

        self.check_with_rich_and_poor_urls(
            self.admin.get_short_url, (self.entry,),
            '<a href="http://example.com/%(hash)s/" target="blank">'
            'http://example.com/%(hash)s/</a>' % {
                'hash': base36(self.entry.pk)},
            '<a href="%(url)s" target="blank">%(url)s</a>' % {
                'url': entry_url})
Ejemplo n.º 10
0
 def test_base36(self):
     self.assertEqual(default.base36(1), '1')
     self.assertEqual(default.base36(100), '2S')
     self.assertEqual(default.base36(46656), '1000')
Ejemplo n.º 11
0
 def get_redirect_url(self, *args, **kwargs):
     return reverse('zinnia:entry_shortlink',
                    args=[base36(self.get_object().pk)])
 def test_base36(self):
     self.assertEqual(default.base36(1), '1')
     self.assertEqual(default.base36(100), '2S')
     self.assertEqual(default.base36(46656), '1000')