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
e751239c
Commit
e751239c
authored
Sep 14, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testOOoServer: reorganize/modernize test
Split into several test classes for easier maintainance
parent
df013e4a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
17 deletions
+38
-17
cloudooo/handler/ooo/tests/testOooServer.py
cloudooo/handler/ooo/tests/testOooServer.py
+38
-17
No files found.
cloudooo/handler/ooo/tests/testOooServer.py
View file @
e751239c
...
@@ -39,8 +39,9 @@ import magic
...
@@ -39,8 +39,9 @@ import magic
from
cloudooo.handler.ooo.tests.testOooMimemapper
import
text_expected_tuple
,
presentation_expected_tuple
from
cloudooo.handler.ooo.tests.testOooMimemapper
import
text_expected_tuple
,
presentation_expected_tuple
class
TestServer
(
TestCase
):
"""Tests for XmlRpc Server. Needs cloudooo server started"""
"""Test XmlRpc Server. Needs cloudooo server started"""
class
TestAllowedExtensions
(
TestCase
):
def
testGetAllowedTextExtensionListByType
(
self
):
def
testGetAllowedTextExtensionListByType
(
self
):
"""Verify if getAllowedExtensionList returns is a list with extension and
"""Verify if getAllowedExtensionList returns is a list with extension and
...
@@ -83,6 +84,10 @@ class TestServer(TestCase):
...
@@ -83,6 +84,10 @@ class TestServer(TestCase):
self
.
assertEquals
(
sorted
([(
a
,
b
)
for
a
,
b
in
msword_allowed_list
if
a
not
in
(
"doc"
,
"docy"
)]),
self
.
assertEquals
(
sorted
([(
a
,
b
)
for
a
,
b
in
msword_allowed_list
if
a
not
in
(
"doc"
,
"docy"
)]),
sorted
(
list
(
filter
(
lambda
(
a
,
b
):
a
not
in
(
"doc"
,
"docy"
),
text_expected_tuple
))))
sorted
(
list
(
filter
(
lambda
(
a
,
b
):
a
not
in
(
"doc"
,
"docy"
),
text_expected_tuple
))))
class
TestConversion
(
TestCase
):
"""Test that conversion of some test documents to various destination format does not fail.
"""
def
ConversionScenarioList
(
self
):
def
ConversionScenarioList
(
self
):
return
[
return
[
# Test Convert Doc -> Odt
# Test Convert Doc -> Odt
...
@@ -129,7 +134,24 @@ class TestServer(TestCase):
...
@@ -129,7 +134,24 @@ class TestServer(TestCase):
"opendocument.presentation"
),
"opendocument.presentation"
),
])
])
def
ConvertScenarioList
(
self
):
return
[
# Test run_convert method
(
'test.doc'
,
open
(
join
(
'data'
,
'test.doc'
)).
read
(),
200
,
''
,
[
'data'
,
'meta'
,
'mime'
],
''
,
'application/vnd.oasis.opendocument.text'
),
# Test run_convert method with invalid file
(
'test.doc'
,
open
(
join
(
'data'
,
'test.doc'
)).
read
()[:
30
],
200
,
''
,
[
'data'
,
'meta'
,
'mime'
],
''
,
'application/vnd.oasis.opendocument.text'
),
]
def
testRunConvertMethod
(
self
):
"""Test run_convert method"""
self
.
runConvertScenarioList
(
self
.
ConvertScenarioList
())
class
TestGetMetadata
(
TestCase
):
def
GetMetadataScenarioList
(
self
):
def
GetMetadataScenarioList
(
self
):
return
[
return
[
# Test method getFileMetadataItemList. Without data converted
# Test method getFileMetadataItemList. Without data converted
...
@@ -191,21 +213,6 @@ class TestServer(TestCase):
...
@@ -191,21 +213,6 @@ class TestServer(TestCase):
self
.
assertEquals
(
metadata_dict
.
get
(
"Reference"
),
"new value"
)
self
.
assertEquals
(
metadata_dict
.
get
(
"Reference"
),
"new value"
)
self
.
assertEquals
(
metadata_dict
.
get
(
"Something"
),
"ABC"
)
self
.
assertEquals
(
metadata_dict
.
get
(
"Something"
),
"ABC"
)
def
ConvertScenarioList
(
self
):
return
[
# Test run_convert method
(
'test.doc'
,
open
(
join
(
'data'
,
'test.doc'
)).
read
(),
200
,
''
,
[
'data'
,
'meta'
,
'mime'
],
''
,
'application/vnd.oasis.opendocument.text'
),
# Test run_convert method with invalid file
(
'test.doc'
,
open
(
join
(
'data'
,
'test.doc'
)).
read
()[:
30
],
200
,
''
,
[
'data'
,
'meta'
,
'mime'
],
''
,
'application/vnd.oasis.opendocument.text'
),
]
def
testRunConvertMethod
(
self
):
"""Test run_convert method"""
self
.
runConvertScenarioList
(
self
.
ConvertScenarioList
())
# XXX: This is a test for ERP5 Backward compatibility,
# XXX: This is a test for ERP5 Backward compatibility,
# and the support to this kind of tests will be dropped.
# and the support to this kind of tests will be dropped.
...
@@ -222,6 +229,8 @@ class TestServer(TestCase):
...
@@ -222,6 +229,8 @@ class TestServer(TestCase):
self
.
assertNotEquals
(
response_dict
[
'data'
],
''
)
self
.
assertNotEquals
(
response_dict
[
'data'
],
''
)
self
.
assertEquals
(
response_dict
[
'mime'
],
'application/pdf'
)
self
.
assertEquals
(
response_dict
[
'mime'
],
'application/pdf'
)
class
TestGenerate
(
TestCase
):
# XXX: This is a test for ERP5 Backward compatibility,
# XXX: This is a test for ERP5 Backward compatibility,
# and the support to this kind of tests will be dropped.
# and the support to this kind of tests will be dropped.
def
testRunGenerateMethodConvertOdsToHTML
(
self
):
def
testRunGenerateMethodConvertOdsToHTML
(
self
):
...
@@ -337,6 +346,8 @@ class TestServer(TestCase):
...
@@ -337,6 +346,8 @@ class TestServer(TestCase):
self
.
assertEquals
(
response_dict
,
{})
self
.
assertEquals
(
response_dict
,
{})
self
.
assertTrue
(
response_message
.
startswith
(
'Traceback'
))
self
.
assertTrue
(
response_message
.
startswith
(
'Traceback'
))
class
TestSetMetadata
(
TestCase
):
def
testRunSetMetadata
(
self
):
def
testRunSetMetadata
(
self
):
"""Test run_setmetadata method, updating the same metadata"""
"""Test run_setmetadata method, updating the same metadata"""
setmetadata_result
=
self
.
proxy
.
run_setmetadata
(
'testMetadata.odt'
,
setmetadata_result
=
self
.
proxy
.
run_setmetadata
(
'testMetadata.odt'
,
...
@@ -377,6 +388,8 @@ class TestServer(TestCase):
...
@@ -377,6 +388,8 @@ class TestServer(TestCase):
self
.
assertEquals
(
response_dict
,
{})
self
.
assertEquals
(
response_dict
,
{})
self
.
assertTrue
(
response_message
.
startswith
(
'Traceback'
))
self
.
assertTrue
(
response_message
.
startswith
(
'Traceback'
))
class
TestGetAllowedTargetItemList
(
TestCase
):
def
testGetAllowedTargetItemList
(
self
):
def
testGetAllowedTargetItemList
(
self
):
"""Test if filter name returns correctly with ERP5 API"""
"""Test if filter name returns correctly with ERP5 API"""
mimetype
=
'application/vnd.oasis.opendocument.text'
mimetype
=
'application/vnd.oasis.opendocument.text'
...
@@ -390,6 +403,8 @@ class TestServer(TestCase):
...
@@ -390,6 +403,8 @@ class TestServer(TestCase):
sorted
([(
a
,
b
)
for
a
,
b
in
response_dict
[
'response_data'
]
if
a
not
in
(
"odt"
,
"docy"
)]),
sorted
([(
a
,
b
)
for
a
,
b
in
response_dict
[
'response_data'
]
if
a
not
in
(
"odt"
,
"docy"
)]),
sorted
(
list
(
filter
(
lambda
(
a
,
b
):
a
not
in
(
"odt"
,
"docy"
),
text_expected_tuple
))))
sorted
(
list
(
filter
(
lambda
(
a
,
b
):
a
not
in
(
"odt"
,
"docy"
),
text_expected_tuple
))))
class
TestGetTableItemList
(
TestCase
):
def
testGetTableItemListFromOdt
(
self
):
def
testGetTableItemListFromOdt
(
self
):
"""Test if getTableItemList can get the table item list from odt file"""
"""Test if getTableItemList can get the table item list from odt file"""
table_list
=
[[
'Developers'
,
''
],
table_list
=
[[
'Developers'
,
''
],
...
@@ -476,6 +491,8 @@ class TestServer(TestCase):
...
@@ -476,6 +491,8 @@ class TestServer(TestCase):
[
'Phone'
,
'+55 (22) 9999-9999'
],
[
'Phone'
,
'+55 (22) 9999-9999'
],
[
'Email'
,
'rafael@tiolive.com'
]],
line_item_list
)
[
'Email'
,
'rafael@tiolive.com'
]],
line_item_list
)
class
TestImagetItemList
(
TestCase
):
def
testGetImageItemListFromOdt
(
self
):
def
testGetImageItemListFromOdt
(
self
):
"""Test if getImageItemList can get the list of images items from odt file"""
"""Test if getImageItemList can get the list of images items from odt file"""
data
=
encodestring
(
open
(
"./data/granulate_test.odt"
).
read
())
data
=
encodestring
(
open
(
"./data/granulate_test.odt"
).
read
())
...
@@ -519,6 +536,8 @@ class TestServer(TestCase):
...
@@ -519,6 +536,8 @@ class TestServer(TestCase):
geted_image
=
decodestring
(
self
.
proxy
.
getImage
(
data
,
image_id
,
"doc"
))
geted_image
=
decodestring
(
self
.
proxy
.
getImage
(
data
,
image_id
,
"doc"
))
self
.
assertEquals
(
original_image
,
geted_image
)
self
.
assertEquals
(
original_image
,
geted_image
)
class
TestParagraphItemList
(
TestCase
):
def
testGetParagraphItemList
(
self
):
def
testGetParagraphItemList
(
self
):
"""Test if getParagraphItemList can get paragraphs correctly from document"""
"""Test if getParagraphItemList can get paragraphs correctly from document"""
data
=
encodestring
(
open
(
"./data/granulate_test.odt"
).
read
())
data
=
encodestring
(
open
(
"./data/granulate_test.odt"
).
read
())
...
@@ -537,6 +556,8 @@ class TestServer(TestCase):
...
@@ -537,6 +556,8 @@ class TestServer(TestCase):
paragraph
=
self
.
proxy
.
getParagraph
(
data
,
1
,
"odt"
)
paragraph
=
self
.
proxy
.
getParagraph
(
data
,
1
,
"odt"
)
self
.
assertEquals
([
''
,
'P1'
],
paragraph
)
self
.
assertEquals
([
''
,
'P1'
],
paragraph
)
class
TestChapterItemList
(
TestCase
):
def
testGetChapterItemList
(
self
):
def
testGetChapterItemList
(
self
):
"""Test if getChapterItemList can get the chapters list correctly from document"""
"""Test if getChapterItemList can get the chapters list correctly from document"""
data
=
encodestring
(
open
(
"./data/granulate_chapters_test.odt"
).
read
())
data
=
encodestring
(
open
(
"./data/granulate_chapters_test.odt"
).
read
())
...
...
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