Exemplo n.º 1
0
 def test_image_draft_shows(self):
     """The image draft is loaded for this user."""
     image(title=get_draft_title(self.u), creator=self.u)
     response = get(self.client, 'gallery.gallery', args=['image'])
     eq_(200, response.status_code)
     doc = pq(response.content)
     assert doc('.image-preview img').attr('src').endswith('098f6b.jpg')
     eq_(1, doc('.image-preview img').length)
Exemplo n.º 2
0
 def test_video_draft_post(self):
     """Posting to the page saves the field values for the video draft."""
     video(title=get_draft_title(self.u), creator=self.u)
     response = post(self.client, "gallery.gallery", {"title": "zTestz"}, args=["image"])
     eq_(200, response.status_code)
     doc = pq(response.content)
     # Preview for all 3 video formats: flv, ogv, webm
     eq_("zTestz", doc('#gallery-upload-modal input[name="title"]').val())
Exemplo n.º 3
0
 def test_image_draft_shows(self):
     """The image draft is loaded for this user."""
     image(title=get_draft_title(self.u), creator=self.u)
     response = get(self.client, "gallery.gallery", args=["image"])
     eq_(200, response.status_code)
     doc = pq(response.content)
     assert doc(".image-preview img").attr("src").endswith("098f6b.jpg")
     eq_(1, doc(".image-preview img").length)
Exemplo n.º 4
0
 def test_video_draft_shows(self):
     """The video draft is loaded for this user."""
     video(title=get_draft_title(self.u), creator=self.u)
     response = get(self.client, 'gallery.gallery', args=['image'])
     eq_(200, response.status_code)
     doc = pq(response.content)
     # Preview for all 3 video formats: flv, ogv, webm
     eq_(3, doc('ul li.video-preview').length)
Exemplo n.º 5
0
 def test_video_draft_shows(self):
     """The video draft is loaded for this user."""
     video(title=get_draft_title(self.u), creator=self.u)
     response = get(self.client, "gallery.gallery", args=["image"])
     eq_(200, response.status_code)
     doc = pq(response.content)
     # Preview for all 3 video formats: flv, ogv, webm
     eq_(3, doc("ul li.video-preview").length)
Exemplo n.º 6
0
 def test_image_title_locale_unique_validation(self):
     """Posting an existing locale/title combination shows a validation
     error."""
     u = User.objects.get(username='******')
     image(creator=u, title=get_draft_title(u))
     post(self.client, 'gallery.upload',
          {'locale': 'de', 'title': 'Hasta la vista',
           'description': 'Auf wiedersehen!'}, args=['image'])
     image(creator=u, title=get_draft_title(u))
     r = post(self.client, 'gallery.upload',
              {'locale': 'de', 'title': 'Hasta la vista',
               'description': 'Auf wiedersehen!'},
              args=['image'])
     eq_(200, r.status_code)
     doc = pq(r.content)
     msg = 'Image with this Locale and Title already exists.'
     assert doc('ul.errorlist li').text().startswith(msg)
Exemplo n.º 7
0
 def test_image_draft_post(self):
     """Posting to the page saves the field values for the image draft."""
     image(title=get_draft_title(self.u), creator=self.u)
     response = post(self.client, "gallery.gallery", {"description": "??", "title": "test"}, args=["image"])
     eq_(200, response.status_code)
     doc = pq(response.content)
     # Preview for all 3 video formats: flv, ogv, webm
     eq_("??", doc("#gallery-upload-modal textarea").html())
     eq_("test", doc('#gallery-upload-modal input[name="title"]').val())
Exemplo n.º 8
0
 def test_video_draft_post(self):
     """Posting to the page saves the field values for the video draft."""
     video(title=get_draft_title(self.u), creator=self.u)
     response = post(self.client,
                     'gallery.gallery', {'title': 'zTestz'},
                     args=['image'])
     eq_(200, response.status_code)
     doc = pq(response.content)
     # Preview for all 3 video formats: flv, ogv, webm
     eq_('zTestz', doc('#gallery-upload-modal input[name="title"]').val())
Exemplo n.º 9
0
 def test_image_title_locale_unique_validation(self):
     """Posting an existing locale/title combination shows a validation
     error."""
     u = User.objects.get(username="******")
     image(creator=u, title=get_draft_title(u))
     post(
         self.client,
         "gallery.upload",
         {"locale": "de", "title": "Hasta la vista", "description": "Auf wiedersehen!"},
         args=["image"],
     )
     image(creator=u, title=get_draft_title(u))
     r = post(
         self.client,
         "gallery.upload",
         {"locale": "de", "title": "Hasta la vista", "description": "Auf wiedersehen!"},
         args=["image"],
     )
     eq_(200, r.status_code)
     doc = pq(r.content)
     msg = "Image with this Locale and Title already exists."
     assert doc("ul.errorlist li").text().startswith(msg)
Exemplo n.º 10
0
 def test_image_draft_post(self):
     """Posting to the page saves the field values for the image draft."""
     image(title=get_draft_title(self.u), creator=self.u)
     response = post(self.client,
                     'gallery.gallery', {
                         'description': '??',
                         'title': 'test'
                     },
                     args=['image'])
     eq_(200, response.status_code)
     doc = pq(response.content)
     # Preview for all 3 video formats: flv, ogv, webm
     eq_('??', doc('#gallery-upload-modal textarea').html())
     eq_('test', doc('#gallery-upload-modal input[name="title"]').val())
Exemplo n.º 11
0
    def test_upload_draft(self):
        """Uploading draft works, sets locale too."""
        u = User.objects.get(username='******')
        image(creator=u, title=get_draft_title(u))

        r = post(self.client, 'gallery.upload',
                 {'locale': 'de', 'title': 'Hasta la vista',
                  'description': 'Auf wiedersehen!'},
                 args=['image'])

        eq_(200, r.status_code)
        img = Image.objects.all()[0]
        eq_('de', img.locale)
        eq_('Hasta la vista', img.title)
        eq_('Auf wiedersehen!', img.description)
Exemplo n.º 12
0
    def test_upload_draft_image(self):
        """Uploading draft image works, sets locale too."""
        u = User.objects.get(username='******')
        img = image(creator=u, title=get_draft_title(u))
        # No thumbnail yet.
        eq_(None, img.thumbnail)

        r = post(self.client, 'gallery.upload',
                 {'locale': 'de', 'title': 'Hasta la vista',
                  'description': 'Auf wiedersehen!'},
                 args=['image'])

        eq_(200, r.status_code)
        img = Image.objects.all()[0]
        eq_('de', img.locale)
        eq_('Hasta la vista', img.title)
        eq_('Auf wiedersehen!', img.description)
        # Thumbnail generated after form is saved.
        eq_(90, img.thumbnail.width)
Exemplo n.º 13
0
    def test_upload_video(self):
        """Uploading a video works."""
        r = self._upload_extension("ogv")
        vid = Video.objects.all()[0]

        eq_(1, Video.objects.count())
        eq_(200, r.status_code)
        json_r = json.loads(r.content)
        eq_("success", json_r["status"])
        file = json_r["file"]
        eq_("test.ogv", file["name"])
        eq_(32, file["width"])
        eq_(32, file["height"])
        assert file["url"].endswith(vid.get_absolute_url())
        eq_("pcraciunoiu", vid.creator.username)
        eq_(get_draft_title(vid.creator), vid.title)
        eq_("Autosaved draft.", vid.description)
        eq_("en-US", vid.locale)
        with open(TEST_VID["ogv"]) as f:
            eq_(f.read(), vid.ogv.read())
Exemplo n.º 14
0
    def test_upload_video(self):
        """Uploading a video works."""
        r = self._upload_extension('ogv')
        vid = Video.objects.all()[0]

        eq_(1, Video.objects.count())
        eq_(200, r.status_code)
        json_r = json.loads(r.content)
        eq_('success', json_r['status'])
        file = json_r['file']
        eq_('test.ogv', file['name'])
        eq_(32, file['width'])
        eq_(32, file['height'])
        assert file['url'].endswith(vid.get_absolute_url())
        eq_('pcraciunoiu', vid.creator.username)
        eq_(get_draft_title(vid.creator), vid.title)
        eq_('Autosaved draft.', vid.description)
        eq_('en-US', vid.locale)
        with open(TEST_VID['ogv']) as f:
            eq_(f.read(), vid.ogv.read())
Exemplo n.º 15
0
    def test_upload_image(self):
        """Uploading an image works."""
        with open(TEST_IMG) as f:
            r = post(self.client, "gallery.upload_async", {"file": f}, args=["image"])
        img = Image.objects.all()[0]

        eq_(1, Image.objects.count())
        eq_(200, r.status_code)
        json_r = json.loads(r.content)
        eq_("success", json_r["status"])
        file = json_r["file"]
        eq_("test.jpg", file["name"])
        eq_(90, file["width"])
        eq_(120, file["height"])
        assert file["url"].endswith(img.get_absolute_url())
        eq_("pcraciunoiu", img.creator.username)
        eq_(150, img.file.width)
        eq_(200, img.file.height)
        eq_(get_draft_title(img.creator), img.title)
        eq_("Autosaved draft.", img.description)
        eq_("en-US", img.locale)
Exemplo n.º 16
0
    def test_upload_draft_image(self):
        """Uploading draft image works, sets locale too."""
        u = User.objects.get(username="******")
        img = image(creator=u, title=get_draft_title(u))
        # No thumbnail yet.
        eq_(None, img.thumbnail)

        r = post(
            self.client,
            "gallery.upload",
            {"locale": "de", "title": "Hasta la vista", "description": "Auf wiedersehen!"},
            args=["image"],
        )

        eq_(200, r.status_code)
        img = Image.objects.all()[0]
        eq_("de", img.locale)
        eq_("Hasta la vista", img.title)
        eq_("Auf wiedersehen!", img.description)
        # Thumbnail generated after form is saved.
        eq_(90, img.thumbnail.width)
Exemplo n.º 17
0
    def test_upload_image(self):
        """Uploading an image works."""
        with open(TEST_IMG) as f:
            r = post(self.client, 'gallery.upload_async', {'file': f},
                     args=['image'])
        img = Image.objects.all()[0]

        eq_(1, Image.objects.count())
        eq_(200, r.status_code)
        json_r = json.loads(r.content)
        eq_('success', json_r['status'])
        file = json_r['file']
        eq_('test.jpg', file['name'])
        eq_(90, file['width'])
        eq_(120, file['height'])
        assert file['url'].endswith(img.get_absolute_url())
        eq_('pcraciunoiu', img.creator.username)
        eq_(150, img.file.width)
        eq_(200, img.file.height)
        eq_(get_draft_title(img.creator), img.title)
        eq_('Autosaved draft.', img.description)
        eq_('en-US', img.locale)