Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added better test to check images have been cached and resized

  • Loading branch information...
commit 3ec263d6370b21a9481c183b5ee153e795971807 1 parent 004fe71
Tim Parkin authored
View
5 formish.egg-info/SOURCES.txt
@@ -209,7 +209,6 @@ formish/dottedDict.py
formish/filehandler.py
formish/fileresource.py
formish/forms.py
-formish/myfileresource.py
formish/renderer.py
formish/util.py
formish/validation.py
@@ -268,6 +267,9 @@ formish/tests/testish/live.ini
formish/tests/testish/run.sh
formish/tests/testish/setup.py
formish/tests/testish/testish.ini
+formish/tests/testish/cache/.gitignore
+formish/tests/testish/testdata/photo.jpg
+formish/tests/testish/testdata/photo.png
formish/tests/testish/testdata/test.txt
formish/tests/testish/testish/__init__.py
formish/tests/testish/testish/wsgiapp.py
@@ -300,6 +302,7 @@ formish/tests/testish/testish/public/css/tripoli/plugins/tripoli.layout.css
formish/tests/testish/testish/public/css/tripoli/plugins/tripoli.negative.css
formish/tests/testish/testish/public/css/tripoli/plugins/tripoli.type.css
formish/tests/testish/testish/public/css/tripoli/plugins/tripoli.visual.css
+formish/tests/testish/testish/public/images/nouploadyet.png
formish/tests/testish/testish/public/js/formish.js
formish/tests/testish/testish/public/js/jquery-1.2.6.min.js
formish/tests/testish/testish/public/js/jquery-sortable.js
View
23 formish/tests/testish/testish/lib/forms.py
@@ -1,10 +1,14 @@
-import logging, os.path, tempfile
+import logging, os.path, tempfile, subprocess
import formish, schemaish, validatish
from formish.filehandler import TempFileHandlerWeb
from testish.lib import xformish
log = logging.getLogger(__name__)
+
+
+IDENTIFY = '/usr/bin/identify'
+
##
# Make sure forms have the doc string with triple quotes
# on a separate line as this file is parsed
@@ -611,10 +615,19 @@ def functest_RequiredStringAndFile(self, sel):#{{{
try: self.assertEqual(sel.get_attribute("//div[@id='resized']/img@src")[-22:-13],"photo.jpg")
except AssertionError, e: self.verificationErrors.append(str(e))
- try: self.assertEqual("300", sel.get_text("css=#actual div"))
- except AssertionError, e: self.verificationErrors.append(str(e))
- try: self.assertEqual("100", sel.get_text("css=#resized div"))
- except AssertionError, e: self.verificationErrors.append(str(e))
+
+ filesrc = sel.get_attribute("//div[@id='actual']/img@src")
+ filesrc = filesrc.split('/')[-1]
+ actualfilepath = 'cache/%s'%filesrc
+ assert os.path.exists(actualfilepath)
+ stdout = subprocess.Popen([IDENTIFY, actualfilepath], stdout=subprocess.PIPE).communicate()[0]
+ assert stdout.endswith('photo.jpg JPEG 300x300 300x300+0+0 DirectClass 8-bit 4.36133kb \n')
+
+ actualfilepath = '%s-100x100'%actualfilepath
+ assert os.path.exists(actualfilepath)
+ stdout = subprocess.Popen([IDENTIFY, actualfilepath], stdout=subprocess.PIPE).communicate()[0]
+ assert stdout.endswith('photo.jpg-100x100 JPEG 100x100 100x100+0+0 DirectClass 8-bit 1.70703kb \n')
+
return#}}}
View
4 formish/tests/testish/testish/resource/root.py
@@ -57,7 +57,9 @@ def get_mimetype(self, filename):
def get_mtime(self, filename):
actualfilename = '%s/%s%s'% (self.tempdir, self.prefix, filename.split('-')[-1])
- return datetime.fromtimestamp( os.path.getmtime(actualfilename) )
+ if os.path.exists(actualfilename):
+ return datetime.fromtimestamp( os.path.getmtime(actualfilename) )
+ return datetime(1970, 1, 1, 0, 0)
def get_file(self, filename):
View
2  formish/tests/testish/testish/templates/base.html
@@ -18,7 +18,7 @@
//<![CDATA[
$(document).ready(function() {
formish();
- setTimeout("$('#uploadedimage img').each( function () { $(this).after('<div>'+$(this).width()+'</div>') ;} );",80)
+ setTimeout("$('#uploadedimage img').each( function () { $(this).after('<div>'+$(this).width()+'px wide</div>') ;} );",80)
});
//]]>
</script>
View
1  formish/tests/testish/testish/templates/form.html
@@ -24,6 +24,7 @@
% if rawdata is not None and 'myFileField' in rawdata:
<div id="uploadedimage">
+<h3>Uploaded Image</h3>
<div id="actual"><img src="/filehandler/${rawdata['myFileField'].filename}" /></div>
<div id="resized"><img src="/filehandler/${rawdata['myFileField'].filename}?size=100x100" /></div>
</div>
View
1  release.sh
@@ -0,0 +1 @@
+python setup.py bdist_egg sdist upload -s -i 43DA9303
View
62 setup.py
@@ -9,7 +9,69 @@
long_description="""\
Formish is a schema backed, templating language agnostic form generation and handling library. It's main features are its granular components and its ability to create quite complex forms (including sequences, groups, sequences of groups, groups of sequences, etc). It has a built in mako templating library but should be straightforward to add other templating systems. It also has strong support for file uploads with a default tempfile storage handler. It uses schemaish for its schema, validatish for validation and convertish for type coercion.
+==========
+Changlelog
+==========
+
+0.5.7 (2009-01-11)
+------------------
+
+BUG FIX: Fixed various problems with File uploads.
+
+* added a default file acccessor that uses python tempfile with a 'store-' file prefix.
+
+0.5.6 (2009-01-09)
+------------------
+
+BUG FIX: Fixed bug when using multi part widgets (e.g. Date Parts) inside a sequence. Added example test case.
+
+* changes to handle new schemaish Invalid exception format
+* added a contains-error class to container classes that do.
+
+0.5.5 (2009-01-08)
+------------------
+
+Add a granular template rendering system (have a look at http://ish.io:8891/CustomisedFormLayout)
+
+0.5.4 (2009-01-06)
+------------------
+
+Removed all * imports apart from those at the module level. Checked against pyflakes.
+
+0.5.3 (2009-01-06)
+------------------
+
+!! API CHANGES !!
+
+* dateFirst becomes date_first (on dateParts widget)
+* allowClear becomes allow_clear (on fileUpload widget)
+* fileHandler becomes filehandler (on fileUpload widget)
+* showImagePreview becomes show_image_preview (on fileUpload widget)
+* noneOption becomes none_option (on select widgets)
+
+Cleaned up repo and fixed bad style in some method attributes and method names
+
+* Added files recommended by pypi including license
+
+
+0.5.2 (2009-01-05)
+------------------
+
+BUG FIX: Added an import except wrapper around the default mako import
+
+
+0.5.1 (2009-01-05)
+------------------
+
+BUG FIX: Problem with redisplayed empty checkboxes after validation
+
+
+0.5 (2009-01-05)
+----------------
+
+NOTE: First External Release
Have a look at `http://ish.io:8891 <http://ish.io:8891>`_ for an example - if this isn't running, please email `support@ish.io <mailto://support@ish.io>`_
+
""",
classifiers=[
"Development Status :: 4 - Beta",
Please sign in to comment.
Something went wrong with that request. Please try again.