Ejemplo n.º 1
0
    def test_gallery_item_ajax_galleriffic(self):
        # create objects
        gallery = Gallery()
        gallery.save()
        gi_obj = GalleryImage(gallery=gallery, state='published')
        gi_obj.save()
        gi_obj.sites.add(Site.objects.get_current())
        ve_obj = VideoEmbed(gallery=gallery, state='published')
        ve_obj.save()
        ve_obj.sites.add(Site.objects.get_current())
        vf_obj = VideoFile(gallery=gallery, state='published', file='test.flv')
        vf_obj.save()
        vf_obj.sites.add(Site.objects.get_current())

        # raise 404 on invalid slug
        self.assertRaises(Http404, views.gallery_item_ajax_galleriffic, request=None, slug='invalid_slug')

        # use galleryimage template for gallery image object
        client = Client()
        response = client.get(reverse('gallery_item_ajax_galleriffic', kwargs={'slug': gi_obj.slug}))
        self.assertTemplateUsed(response, 'gallery/ajax/galleriffic_galleryimage.html')
        
        # use videoembed template for video embed object
        response = client.get(reverse('gallery_item_ajax_galleriffic', kwargs={'slug': ve_obj.slug}))
        self.assertTemplateUsed(response, 'gallery/ajax/galleriffic_videoembed.html')
        
        # use videofile template for video file object
        response = client.get(reverse('gallery_item_ajax_galleriffic', kwargs={'slug': vf_obj.slug}))
        self.assertTemplateUsed(response, 'gallery/ajax/galleriffic_videofile.html')
Ejemplo n.º 2
0
 def test_video_file_response(self):
     # create a video file object
     gallery = Gallery()
     gallery.save()
     obj = VideoFile(gallery=gallery, file='test.flv')
     obj.save()
     
     # if the videofile_large photosize does not exist, use default dimensions (500x300)
     result = views.videofile_response({'object': obj})
     self.failUnless('width:500px' in result)
     self.failUnless('height:300px' in result)
     
     # if the videofile_large photosize exists, use its dimension
     PhotoSize(name="videofile_large", width=606, height=340).save()
     obj = VideoFile(gallery=gallery, file='test.flv')
     obj.save()
     result = views.videofile_response({'object': obj})
     self.failUnless('width:606px' in result)
     self.failUnless('height:340px' in result)