Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_rtl_support
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
erp5_rtl_support
Commits
614f73f6
Commit
614f73f6
authored
Dec 17, 2012
by
Pere Cortes
Committed by
Sebastien Robin
Jan 31, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
image_unit_test added and testSafeImage fixed
parent
6e8a2d02
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1280 additions
and
11 deletions
+1280
-11
bt5/erp5_safeimage/SkinTemplateItem/portal_skins/erp5_safeimage/img/image_unit_test.jpg.xml
...m/portal_skins/erp5_safeimage/img/image_unit_test.jpg.xml
+1255
-0
bt5/erp5_safeimage/TestTemplateItem/testSafeImage.py
bt5/erp5_safeimage/TestTemplateItem/testSafeImage.py
+24
-10
bt5/erp5_safeimage/bt/revision
bt5/erp5_safeimage/bt/revision
+1
-1
No files found.
bt5/erp5_safeimage/SkinTemplateItem/portal_skins/erp5_safeimage/img/image_unit_test.jpg.xml
0 → 100644
View file @
614f73f6
This diff is collapsed.
Click to expand it.
bt5/erp5_safeimage/TestTemplateItem/testSafeImage.py
View file @
614f73f6
#from Products.ERP5.Document.Image import Image
#from Products.ERP5Type.tests.utils import FileUpload
import
Image
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
import
transaction
from
zLOG
import
LOG
,
INFO
,
ERROR
from
zLOG
import
LOG
,
INFO
,
ERROR
import
json
from
cStringIO
import
StringIO
import
os
...
...
@@ -20,7 +18,8 @@ class FileUpload(file):
def
makeFilePath
(
name
):
return
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'tmp'
,
name
)
#return os.path.join(os.path.dirname(__file__), 'tmp', name)
return
name
def
makeFileUpload
(
name
,
as_name
=
None
):
if
as_name
is
None
:
...
...
@@ -51,25 +50,40 @@ class TestSafeImage(ERP5TypeTestCase):
def
_createImage
(
self
):
portal
=
self
.
getPortalObject
()
_image
=
makeFileUpload
(
'image_test.jpg'
)
image
=
portal
.
restrictedTraverse
(
'portal_skins/erp5_safeimage/img/image_unit_test.jpg'
)
path_image
=
"tmp/image_unit_test.jpg"
fd
=
os
.
open
(
path_image
,
os
.
O_CREAT
|
os
.
O_RDWR
)
os
.
write
(
fd
,
str
(
image
.
data
))
os
.
close
(
fd
)
_image
=
makeFileUpload
(
path_image
)
image
=
self
.
image_module
.
newContent
(
portal_type
=
'Image'
,
title
=
'testImage'
,
id
=
'testImage'
,
file
=
_image
,
filename
=
'testImage'
)
return
image
def
_createTileImage
(
self
):
portal
=
self
.
getPortalObject
()
tile_image
=
makeFileUpload
(
'image_test.jpg'
)
image
=
portal
.
restrictedTraverse
(
'portal_skins/erp5_safeimage/img/image_unit_test.jpg'
)
path_image
=
"tmp/image_unit_test.jpg"
fd
=
os
.
open
(
path_image
,
os
.
O_CREAT
|
os
.
O_RDWR
)
os
.
write
(
fd
,
str
(
image
.
data
))
os
.
close
(
fd
)
tile_image
=
makeFileUpload
(
path_image
)
tile
=
self
.
image_module
.
newContent
(
portal_type
=
'Image Tile'
,
title
=
'testTile'
,
id
=
'testTile'
,
file
=
tile_image
,
filename
=
'testTile'
)
return
tile
return
tile
def
_createTileImageTransformed
(
self
):
portal
=
self
.
getPortalObject
()
tile_image_transformed
=
makeFileUpload
(
'image_test.jpg'
)
image
=
portal
.
restrictedTraverse
(
'portal_skins/erp5_safeimage/img/image_unit_test.jpg'
)
path_image
=
"tmp/image_unit_test.jpg"
fd
=
os
.
open
(
path_image
,
os
.
O_CREAT
|
os
.
O_RDWR
)
os
.
write
(
fd
,
str
(
image
.
data
))
os
.
close
(
fd
)
tile_image_transformed
=
makeFileUpload
(
path_image
)
tile_transformed
=
self
.
image_module
.
newContent
(
portal_type
=
'Image Tile Transformed'
,
title
=
'testTileTransformed'
,
id
=
'testTileTransformed'
,
file
=
tile_image_transformed
,
filename
=
'testTileTransformed'
)
return
tile_transformed
return
tile_transformed
def
test_01_CreateImage
(
self
):
image
=
self
.
_createImage
()
...
...
@@ -123,7 +137,7 @@ class TestSafeImage(ERP5TypeTestCase):
self
.
assertNotEqual
(
tile_transformed
,
None
)
image_property
=
getattr
(
tile_transformed
,
"ImageProperties.xml"
,
None
)
self
.
assertEquals
(
image_property
.
getData
(),
"""<IMAGE_PROPERTIES WIDTH="660" HEIGHT="495" NUMTILES="
9
" NUMIMAGES="1" VERSION="1.8" TILESIZE="256" />"""
)
"""<IMAGE_PROPERTIES WIDTH="660" HEIGHT="495" NUMTILES="
52
" NUMIMAGES="1" VERSION="1.8" TILESIZE="256" />"""
)
self
.
assertNotEqual
(
image_property
,
None
)
self
.
assertEquals
(
"Embedded File"
,
image_property
.
getPortalType
())
image_transform
=
getattr
(
tile_transformed
,
"TransformFile.txt"
,
None
)
...
...
bt5/erp5_safeimage/bt/revision
View file @
614f73f6
6
\ No newline at end of file
7
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment