Skip to content

Commit

Permalink
started test for crop-view
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Feb 20, 2014
1 parent 49ee305 commit 24c8e3a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/plone/app/imagecropping/tests/test_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from plone.app.testing import TEST_USER_NAME
from plone.app.testing import TEST_USER_PASSWORD
from plone.testing.z2 import Browser
from Products.CMFPlone.utils import _createObjectByType

import transaction
import unittest2 as unittest
Expand All @@ -24,21 +23,22 @@ def setUp(self):
self.browser.handleErrors = False
self.browser.addHeader('Authorization', 'Basic %s:%s' % (
TEST_USER_NAME, TEST_USER_PASSWORD,))
self.createSingleImageType()

def createSingleImageType(self):
# create test image as testuser
_createObjectByType('Image', self.portal, 'testimage',
title=u"I'm a testing Image")
self.portal.invokeFactory('Image', 'testimage',
title=u"I'm a testing Image")
self.img = self.portal['testimage']
self.img.reindexObject()
transaction.commit()

self.img = self.portal.testimage
f = file(join(dirname(tests.__file__), 'plone-logo.png'))
self.img.setImage(f)
f.close()

def test_singleimage_editorview(self):
""" """
self.createSingleImageType()
# is there the cropping action tab
self.browser.open("%s/view" % self.img.absolute_url())
self.assertIn("Cropping", self.browser.contents)
Expand All @@ -56,5 +56,11 @@ def test_singleimage_editorview(self):
self.assertIn(u"Save cropping information", self.browser.contents)
self.assertIn(u"Remove cropping information", self.browser.contents)

def test_editview_crop(self):
request = self.layer['request']
request.form.update({'x1': 1.0, 'y1': 2.7, 'x2': 10.6, 'y2': 8.4})
cropview = self.img.restrictedTraverse('@@croppingeditor')
cropview._crop()

def tearDown(self):
self.portal.manage_delObjects(['testimage', ])

0 comments on commit 24c8e3a

Please sign in to comment.