From 24c8e3aec9951b464f90c0a0dac953e8dd0a17c6 Mon Sep 17 00:00:00 2001 From: Tom Gross Date: Thu, 20 Feb 2014 05:45:00 +0100 Subject: [PATCH] started test for crop-view --- src/plone/app/imagecropping/tests/test_editor.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/plone/app/imagecropping/tests/test_editor.py b/src/plone/app/imagecropping/tests/test_editor.py index e3a0ebbb..4917e819 100644 --- a/src/plone/app/imagecropping/tests/test_editor.py +++ b/src/plone/app/imagecropping/tests/test_editor.py @@ -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 @@ -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) @@ -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', ])