Exemple #1
0
    def test_get(self):

        views_h = ViewHandler()
        static_images_dir = self.generate_test_dirs()
        pyntrest_handler = PyntrestHandler(self.mip, static_images_dir)
        self.addCleanup(rmtree, path.join(self.sip, 'images'), True)
        views_h.set_pyntrest_handler(pyntrest_handler)

        self.assertRaises(TypeError, views_h.get)

        request = HttpRequest()
        request.path = '///'
        self.assertIs(HttpResponseRedirect, type(views_h.get(request)))

        request = HttpRequest()
        request.path = '/index.html'
        self.assertIs(HttpResponseRedirect, type(views_h.get(request)))

        request = HttpRequest()
        request.path = ''
        redirect = views_h.get(request)
        self.assertIs(HttpResponseRedirect, type(redirect))
        self.assertEquals('/', redirect.url)

        request = HttpRequest()
        request.path = '/notexistingalbum'

        request = HttpRequest()
        request.path = '/'
        response = type(views_h.get(request))
        self.assertIs(HttpResponse, response)
        self.assertEquals(200, response.status_code)
    def test(self):
        test_images_dir, static_images_dir = self.generate_test_dirs()
        pyh = PyntrestHandler(test_images_dir, static_images_dir)
        context = pyh.generate_view_context('/')

        self.assertEquals(pyntrest_config.IMAGE_THUMB_WIDTH,
                          context['col_width'])
        self.assertEquals(pyntrest_config.IMAGE_THUMB_HEIGHT,
                          context['col_height'])
        self.assertEquals(pyntrest_config.WORDING_ALBUM,
                          context['lang_albums'])
        self.assertEquals(pyntrest_config.WORDING_IMAGES,
                          context['lang_images'])

        self.assertEquals('title', context['page_title'])
        self.assertEquals('desc', context['album_description'])

        breadcrumbs = context['breadcrumbs']
        images = context['images']
        subalbums = context['subalbums']

        self.assertEqual(1, len(breadcrumbs))
        self.assertEqual(4, len(images))
        self.assertEqual(1, len(subalbums))
 def test_init(self):
     self.assertRaises(TypeError, PyntrestHandler)
     self.assertRaises(TypeError, PyntrestHandler, '')
     test_images_dir, static_images_dir = self.generate_test_dirs()
     pyh = PyntrestHandler(test_images_dir, static_images_dir)
     self.assertIsNotNone(pyh)
Exemple #4
0
"""WSGI-hook for Pyntrest to combine Django with a WSGI-compatible web
server like Apache HTTP or Unicorn."""

# The following two lines MUST stick to the top in that order 
# right on top. Otherwise WSGI-usage will not work. 
from os import environ
environ.setdefault('DJANGO_SETTINGS_MODULE', 'pyntrest_project.settings')

from django.core.wsgi import get_wsgi_application
from pyntrest.pyntrest_core import PyntrestHandler
from pyntrest.pyntrest_config import YOUR_IMAGE_FOLDER, STATIC_PATH

# run Pyntrest's system initialization procedure
pyntrest_handler = PyntrestHandler(YOUR_IMAGE_FOLDER, STATIC_PATH)
pyntrest_handler.on_startup()

application = get_wsgi_application()
Exemple #5
0
 def __init__(self):
     """Constructor"""
     self.pyntrest_handler = PyntrestHandler(YOUR_IMAGE_FOLDER, STATIC_PATH)