Fixes
This commit is contained in:
parent
20cc7dff36
commit
7eaaa2c411
7 changed files with 253 additions and 2 deletions
63
tests/imagefieldtest.py
Normal file
63
tests/imagefieldtest.py
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
from bottle import FileUpload
|
||||
from paramecio.cromosoma.webmodel import WebModel
|
||||
from paramecio.cromosoma.extrafields.imagefield import ImageField
|
||||
from paramecio.citoplasma.httputils import GetPostFiles
|
||||
from settings import config
|
||||
import unittest
|
||||
|
||||
class TestFieldMethods(unittest.TestCase):
|
||||
|
||||
def test_imagefield(self):
|
||||
|
||||
f=open('tests/images/image.jpg', 'rb')
|
||||
|
||||
GetPostFiles.files={}
|
||||
|
||||
GetPostFiles.files['image_file']=FileUpload(f, 'image_file', 'image.jpg')
|
||||
|
||||
field=ImageField('image', 'tests/images/uploads', module=None, size=255, required=False)
|
||||
|
||||
field.check('')
|
||||
|
||||
print(field.txt_error)
|
||||
|
||||
self.assertFalse(field.error)
|
||||
|
||||
pass
|
||||
|
||||
|
||||
"""from settings import config
|
||||
from bottle import FileUpload
|
||||
from paramecio.cromosoma.webmodel import WebModel
|
||||
from paramecio.cromosoma.imagefield import ImageField
|
||||
from paramecio.citoplasma.httputils import GetPostFiles
|
||||
import unittest
|
||||
|
||||
class TestImageFieldMethods(unittest.TestCase):
|
||||
|
||||
def test_image(self):
|
||||
#name, save_folder, module=None, size=255, required=False)
|
||||
|
||||
#FileUpload(fileobj, name, filename
|
||||
x=0
|
||||
pass
|
||||
|
||||
GetPostFiles.files=
|
||||
|
||||
field=ImageField(, 'test/image', module=None, size=255, required=False)
|
||||
|
||||
field.required=True
|
||||
|
||||
field.check('')
|
||||
|
||||
self.assertTrue(field.error)
|
||||
|
||||
field.check('content')
|
||||
|
||||
self.assertFalse(field.error)
|
||||
|
||||
value=field.check("injection_'")
|
||||
|
||||
self.assertEqual(value, "injection_\\'")"""
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue