Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
cloudooo
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Tyagov
cloudooo
Commits
f6eb36a4
Commit
f6eb36a4
authored
Oct 11, 2016
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x2t: add docy tests with image
parent
95eb437e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
1 deletion
+28
-1
cloudooo/handler/x2t/tests/data/test_with_image.docx
cloudooo/handler/x2t/tests/data/test_with_image.docx
+0
-0
cloudooo/handler/x2t/tests/data/test_with_image.docy
cloudooo/handler/x2t/tests/data/test_with_image.docy
+0
-0
cloudooo/handler/x2t/tests/testX2tHandler.py
cloudooo/handler/x2t/tests/testX2tHandler.py
+23
-0
cloudooo/handler/x2t/tests/testX2tServer.py
cloudooo/handler/x2t/tests/testX2tServer.py
+5
-1
No files found.
cloudooo/handler/x2t/tests/data/test_with_image.docx
0 → 100644
View file @
f6eb36a4
File added
cloudooo/handler/x2t/tests/data/test_with_image.docy
0 → 100644
View file @
f6eb36a4
File added
cloudooo/handler/x2t/tests/testX2tHandler.py
View file @
f6eb36a4
...
@@ -58,6 +58,29 @@ class TestHandler(HandlerTestCase):
...
@@ -58,6 +58,29 @@ class TestHandler(HandlerTestCase):
y_body_data
=
ZipFile
(
StringIO
(
y_data
)).
open
(
"body.txt"
).
read
()
y_body_data
=
ZipFile
(
StringIO
(
y_data
)).
open
(
"body.txt"
).
read
()
self
.
assertTrue
(
y_body_data
.
startswith
(
"XLSY;v2;10579;"
),
"%r... does not start with 'XLSY;v2;10579;'"
%
(
y_body_data
[:
20
],))
self
.
assertTrue
(
y_body_data
.
startswith
(
"XLSY;v2;10579;"
),
"%r... does not start with 'XLSY;v2;10579;'"
%
(
y_body_data
[:
20
],))
def
testConvertDocx
(
self
):
"""Test conversion of docx to docy and back"""
y_data
=
Handler
(
self
.
tmp_url
,
open
(
"data/test_with_image.docx"
).
read
(),
"docx"
,
**
self
.
kw
).
convert
(
"docy"
)
y_zip
=
ZipFile
(
StringIO
(
y_data
))
y_body_data
=
y_zip
.
open
(
"body.txt"
).
read
()
self
.
assertTrue
(
y_body_data
.
startswith
(
"DOCY;v5;2795;"
),
"%r... does not start with 'DOCY;v5;2795;'"
%
(
y_body_data
[:
20
],))
y_zip
.
open
(
"media/image1.png"
)
x_data
=
Handler
(
self
.
tmp_url
,
y_data
,
"docy"
,
**
self
.
kw
).
convert
(
"docx"
)
# magic inspired by https://github.com/minad/mimemagic/pull/19/files
self
.
assertIn
(
"word/"
,
x_data
[:
2000
])
def
testConvertDocy
(
self
):
"""Test conversion of docy to docx and back"""
x_data
=
Handler
(
self
.
tmp_url
,
open
(
"data/test_with_image.docy"
).
read
(),
"docy"
,
**
self
.
kw
).
convert
(
"docx"
)
self
.
assertIn
(
"word/"
,
x_data
[:
2000
])
y_data
=
Handler
(
self
.
tmp_url
,
x_data
,
"docx"
,
**
self
.
kw
).
convert
(
"docy"
)
y_zip
=
ZipFile
(
StringIO
(
y_data
))
y_body_data
=
y_zip
.
open
(
"body.txt"
).
read
()
self
.
assertTrue
(
y_body_data
.
startswith
(
"DOCY;v5;7519;"
),
"%r... does not start with 'DOCY;v5;7519;'"
%
(
y_body_data
[:
20
],))
y_zip
.
open
(
"media/image1.png"
)
def
testgetMetadataFromImage
(
self
):
def
testgetMetadataFromImage
(
self
):
"""Test getMetadata not implemented form yformats"""
"""Test getMetadata not implemented form yformats"""
handler
=
Handler
(
self
.
tmp_url
,
""
,
"xlsy"
,
**
self
.
kw
)
handler
=
Handler
(
self
.
tmp_url
,
""
,
"xlsy"
,
**
self
.
kw
)
...
...
cloudooo/handler/x2t/tests/testX2tServer.py
View file @
f6eb36a4
...
@@ -35,10 +35,14 @@ class TestServer(TestCase):
...
@@ -35,10 +35,14 @@ class TestServer(TestCase):
return
[
return
[
(
join
(
'data'
,
'test.xlsx'
),
"xlsx"
,
"xlsy"
,
"application/zip"
),
(
join
(
'data'
,
'test.xlsx'
),
"xlsx"
,
"xlsy"
,
"application/zip"
),
(
join
(
'data'
,
'test.xlsy'
),
"xlsy"
,
"xlsx"
,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
),
(
join
(
'data'
,
'test.xlsy'
),
"xlsy"
,
"xlsx"
,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
),
(
join
(
'data'
,
'test_with_image.docx'
),
"docx"
,
"docy"
,
"application/zip"
),
# Here, the content type should be application/vnd.openxmlformats-officedocument.wordprocessingml.document
# but "magic" seems to not detect it correctly. However, the document can be read correctly by LibreOffice.
(
join
(
'data'
,
'test_with_image.docy'
),
"docy"
,
"docx"
,
"application/octet-stream"
),
]
]
def
testConvertHtmltoPdf
(
self
):
def
testConvertHtmltoPdf
(
self
):
"""Converts xlsx
to xlsy and xlsy to xls
x"""
"""Converts xlsx
,docx to their y format and y to
x"""
self
.
runConversionList
(
self
.
ConversionScenarioList
())
self
.
runConversionList
(
self
.
ConversionScenarioList
())
def
FaultConversionScenarioList
(
self
):
def
FaultConversionScenarioList
(
self
):
...
...
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