Ejemplo n.º 1
0
    def testExifPageVariables(self):
        """exif page template variables"""
        self._setTemplate("group basic;\n" \
                'page(gallery, css, js, class, tmpl, rootdir, copyright,' \
                '           album, photo, prev, next) ::=' \
                ' "\'$gallery.title$\'' \
                ' $css$' \
                ' $js$' \
                ' $class$' \
                ' $tmpl$' \
                ' $rootdir$' \
                ' $copyright$' \
                ' p:$prev.title$' \
                ' n:$next.title$' \
                ' $album.title$' \
                ' $photo.exif: {e | n:$e.name$v:$e.value$}$"')

        f = StringIO()
        album = Album()
        album.title = 'a title'
        album.dir = 'a/b/c'
        parent = self.tmpl.gallery
        parent.subalbums.append(album)

        p1 = Photo()
        p1.title = 'p1'
        p1.name = 'n1'
        p1.album = album

        p1.exif.append(Exif('ea', 'ev'))
        p1.exif.append(Exif('ez', 'eq'))

        p2 = Photo()
        p2.title = 'p2'
        p2.name = 'n2'
        p2.album = album

        album.photos.extend([p1, p2])

        self.tmpl.photoPage(f, p1)

        expected = '\'danlann title test\'' \
                ' css/danlann.css' \
                ' js/jquery.jsjs/danlann.js' \
                ' photo' \
                ' basic/photo' \
                ' ../../..' \
                ' (cc)' \
                ' p:' \
                ' n:p2' \
                ' a title' \
                ' n:eav:evn:ezv:eq\n'
        self.assertEquals(expected, f.getvalue())
Ejemplo n.º 2
0
    def testAlbumPageVairables(self):
        """album page template variables"""
        self._setTemplate('group basic;\n' \
                'page(gallery, css, js, class, tmpl, rootdir, copyright,' \
                '           album, parent, prev, next) ::=' \
                ' "\'$gallery.title$\'' \
                ' $css$' \
                ' $js$' \
                ' $class$' \
                ' $tmpl$' \
                ' $rootdir$' \
                ' $copyright$' \
                ' p:$prev.title$' \
                ' n:$next.title$' \
                ' $parent.title$"')

        f = StringIO()
        a1 = Album()
        a1.title = 'a 1 title'
        a1.dir = 'a/b/c'
        a2 = Album()
        a2.title = 'a 2 title'
        a2.dir = 'a/b/d'
        parent = self.tmpl.gallery
        parent.subalbums.extend([a1, a2])

        self.tmpl.albumPage(f, a1, parent)

        expected = '\'danlann title test\'' \
                ' css/danlann.css' \
                ' js/jquery.jsjs/danlann.js' \
                ' album' \
                ' album' \
                ' ../../..' \
                ' (cc)' \
                ' p:' \
                ' n:a 2 title' \
                ' danlann title test\n'
        self.assertEquals(expected, f.getvalue())