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
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
cloudooo
Commits
f013ec03
Commit
f013ec03
authored
Jun 07, 2011
by
Priscila Manhaes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refator to use cloudoootestcase
parent
3aecbb02
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
38 deletions
+11
-38
cloudooo/handler/ooo/tests/testOooAllFormat.py
cloudooo/handler/ooo/tests/testOooAllFormat.py
+11
-38
No files found.
cloudooo/handler/ooo/tests/testOooAllFormat.py
View file @
f013ec03
...
@@ -26,69 +26,42 @@
...
@@ -26,69 +26,42 @@
#
#
##############################################################################
##############################################################################
from
xmlrpclib
import
ServerProxy
,
Fault
from
cloudooo.tests.cloudoooTestCase
import
TestCase
,
make_suite
from
base64
import
encodestring
,
decodestring
from
cloudooo.tests.handlerTestCase
import
HandlerTestCase
,
make_suite
import
magic
file_detector
=
magic
.
Magic
()
class
TestAllFormats
(
TestCase
):
DAEMON
=
True
class
TestAllFormats
(
HandlerTestCase
):
"""Test XmlRpc Server. Needs cloudooo server started"""
"""Test XmlRpc Server. Needs cloudooo server started"""
def
afterSetUp
(
self
):
"""Create connection with cloudooo server"""
self
.
proxy
=
ServerProxy
(
"http://%s:%s/RPC2"
%
(
self
.
hostname
,
self
.
cloudooo_port
))
def
testTextFormats
(
self
):
def
testTextFormats
(
self
):
"""Test all text formats"""
"""Test all text formats"""
self
.
runTestForType
(
'
odt'
,
'text'
,
'data/test.od
t'
)
self
.
runTestForType
(
'
data/test.odt'
,
'odt'
,
'tex
t'
)
def
testPresentationFormats
(
self
):
def
testPresentationFormats
(
self
):
"""Test all presentation formats"""
"""Test all presentation formats"""
self
.
runTestForType
(
'
odp'
,
'presentation'
,
'data/test.odp
'
)
self
.
runTestForType
(
'
data/test.odp'
,
'odp'
,
'presentation
'
)
def
testDrawingFormats
(
self
):
def
testDrawingFormats
(
self
):
"""Test all drawing formats"""
"""Test all drawing formats"""
self
.
runTestForType
(
'
odg'
,
'drawing'
,
'data/test.od
g'
)
self
.
runTestForType
(
'
data/test.odg'
,
'odg'
,
'drawin
g'
)
def
testSpreadSheetFormats
(
self
):
def
testSpreadSheetFormats
(
self
):
"""Test all spreadsheet formats"""
"""Test all spreadsheet formats"""
self
.
runTestForType
(
'
ods'
,
'spreadsheet'
,
'data/test.ods
'
)
self
.
runTestForType
(
'
data/test.ods'
,
'ods'
,
'spreadsheet
'
)
def
testWebFormats
(
self
):
def
testWebFormats
(
self
):
"""Test all web formats"""
"""Test all web formats"""
self
.
runTestForType
(
'
html'
,
'web'
,
'data/test.html
'
)
self
.
runTestForType
(
'
data/test.html'
,
'html'
,
'web
'
)
def
testGlobalFormats
(
self
):
def
testGlobalFormats
(
self
):
"""Test all global formats"""
"""Test all global formats"""
self
.
runTestForType
(
'
sxg'
,
'global'
,
'data/test.sxg
'
)
self
.
runTestForType
(
'
data/test.sxg'
,
'sxg'
,
'global
'
)
def
runTestForType
(
self
,
source_format
,
document_type
,
filename
):
def
runTestForType
(
self
,
input_url
,
source_format
,
document_type
):
"""Generic test"""
"""Generic test for converting all formats"""
data
=
open
(
filename
,
'r'
).
read
()
request
=
{
'document_type'
:
document_type
}
request
=
{
'document_type'
:
document_type
}
extension_list
=
self
.
proxy
.
getAllowedExtensionList
(
request
)
extension_list
=
self
.
proxy
.
getAllowedExtensionList
(
request
)
fault_list
=
[]
fault_list
=
[]
for
extension
in
extension_list
:
for
extension
in
extension_list
:
try
:
self
.
_testConvertFile
(
input_url
,
source_format
,
extension
[
0
],
None
)
data_output
=
self
.
proxy
.
convertFile
(
encodestring
(
data
),
source_format
,
extension
[
0
])
magic_result
=
file_detector
.
from_buffer
(
decodestring
(
data_output
))
file_is_empty
=
magic_result
.
endswith
(
": empty"
)
if
file_is_empty
:
fault_list
.
append
((
source_format
,
extension
[
0
],
magic_result
))
except
Fault
,
err
:
fault_list
.
append
((
source_format
,
extension
[
0
],
err
.
faultString
))
if
fault_list
:
template_message
=
'input_format: %r
\
n
output_format: %r
\
n
traceback:
\
n
%s'
message
=
'
\
n
'
.
join
([
template_message
%
fault
for
fault
in
fault_list
])
self
.
fail
(
'Failed Conversions:
\
n
'
+
message
)
def
test_suite
():
def
test_suite
():
return
make_suite
(
TestAllFormats
)
return
make_suite
(
TestAllFormats
)
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