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
72da57bf
Commit
72da57bf
authored
Apr 23, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ooo: target libreoffice 7.5
( tested with 7.5.2.2 )
parent
fbd8591e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
299 additions
and
216 deletions
+299
-216
cloudooo/handler/ooo/mimemapper.py
cloudooo/handler/ooo/mimemapper.py
+10
-4
cloudooo/handler/ooo/tests/testOooAllFormatERP5Compatibility.py
...oo/handler/ooo/tests/testOooAllFormatERP5Compatibility.py
+5
-0
cloudooo/handler/ooo/tests/testOooHandler.py
cloudooo/handler/ooo/tests/testOooHandler.py
+208
-118
cloudooo/handler/ooo/tests/testOooMimemapper.py
cloudooo/handler/ooo/tests/testOooMimemapper.py
+60
-88
cloudooo/handler/ooo/tests/testOooServer.py
cloudooo/handler/ooo/tests/testOooServer.py
+13
-5
cloudooo/handler/ooo/tests/testOooUnoMimemapper.py
cloudooo/handler/ooo/tests/testOooUnoMimemapper.py
+1
-1
cloudooo/manager.py
cloudooo/manager.py
+2
-0
No files found.
cloudooo/handler/ooo/mimemapper.py
View file @
72da57bf
...
...
@@ -85,6 +85,7 @@ class MimeMapper:
alternative_extension_dict
=
{
'Microsoft Excel 2007 XML'
:
'ms.xlsx'
,
'Microsoft Excel 2007-2013 XML'
:
'ms.xlsx'
,
'Excel 2007–365'
:
'ms.xlsx'
,
'Microsoft Excel 5.0'
:
'5.xls'
,
'Microsoft Excel 95'
:
'95.xls'
,
'Microsoft PowerPoint 2007 XML AutoPlay'
:
'ms.ppsx'
,
...
...
@@ -93,8 +94,10 @@ class MimeMapper:
'Microsoft PowerPoint 2007-2013 XML'
:
'ms.pptx'
,
'Microsoft Word 2007 XML'
:
'ms.docx'
,
'Microsoft Word 2007-2013 XML'
:
'ms.docx'
,
'Word 2007–365'
:
'ms.docx'
,
'Microsoft Word 6.0'
:
'6.doc'
,
'Microsoft Word 95'
:
'95.doc'
,
'TIFF - Tagged Image File Format'
:
'tiff'
,
}
uno_path
=
kw
.
get
(
"uno_path"
,
environ
.
get
(
'uno_path'
))
office_binary_path
=
kw
.
get
(
"office_binary_path"
,
...
...
@@ -115,14 +118,15 @@ class MimeMapper:
filter_dict
,
type_dict
=
json
.
loads
(
stdout
)
ooo_disable_filter_list
=
kw
.
get
(
"ooo_disable_filter_list"
)
or
[]
+
[
#
'writer_jpg_Export', # Seems not working from cloudooo in Libre Office 4.3.3.
2
# 'writer_png_Export', # Seems not working from cloudooo in Libre Office 4.3.3.2
# 'draw_eps_Export', # Seems not working from cloudooo in Libre Office 5.0.0.5
# 'impress_eps_Export', # Seems not working from cloudooo in Libre Office 5.0.0.5
#
https://bugs.documentfoundation.org/show_bug.cgi?id=11725
2
'writer_web_jpg_Export'
,
'writer_web_png_Export'
,
'writer_web_webp_Export'
,
]
ooo_disable_filter_name_list
=
kw
.
get
(
"ooo_disable_filter_name_list"
)
or
[]
+
[
'Text'
,
# Use 'Text - Choose Encoding' instead
'Text (StarWriter/Web)'
,
# Use 'Text - Choose Encoding (Writer/Web)' instead
'ODF Drawing (Impress)'
,
# broken for presentation
]
for
filter_name
,
value
in
filter_dict
.
items
():
if
filter_name
in
ooo_disable_filter_list
:
...
...
@@ -130,6 +134,8 @@ class MimeMapper:
ui_name
=
value
.
get
(
'UIName'
)
filter_type
=
value
.
get
(
'Type'
)
filter_type_dict
=
type_dict
.
get
(
filter_type
)
if
not
filter_type_dict
:
continue
if
not
ui_name
:
ui_name
=
filter_type_dict
.
get
(
"UIName"
)
if
ui_name
in
ooo_disable_filter_name_list
or
'Template'
in
ui_name
:
...
...
cloudooo/handler/ooo/tests/testOooAllFormatERP5Compatibility.py
View file @
72da57bf
...
...
@@ -72,4 +72,9 @@ class TestAllFormatsERP5Compatibility(TestCase):
data_output
=
data_output
[
'data'
]
file_type
=
self
.
_getFileType
(
data_output
)
self
.
assertNotIn
(
": empty"
,
file_type
)
if
source_format
!=
extension
:
# when no filter exist for destination format, the document is not converted
# but silently returned in source format, the assertion below should detect
# this.
self
.
assertNotEqual
(
source_mimetype
,
file_type
)
cloudooo/handler/ooo/tests/testOooHandler.py
View file @
72da57bf
...
...
@@ -200,15 +200,17 @@ class TestHandler(HandlerTestCase):
def
get
(
*
args
,
**
kw
):
return
sorted
(
Handler
.
getAllowedConversionFormatList
(
*
args
,
**
kw
))
text_plain_output_list
=
[
(
'application/msword'
,
'Microsoft Word 97-2003'
),
(
'application/epub+zip'
,
'EPUB Document'
),
(
'application/msword'
,
'Word 97–2003'
),
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/rtf'
,
'Rich Text'
),
(
'application/vnd.ms-word.document.macroEnabled.12'
,
'Word 2007–365 VBA'
),
(
'application/vnd.oasis.opendocument.text'
,
'ODF Text Document'
),
(
'application/vnd.oasis.opendocument.text-flat-xml'
,
'Flat XML ODF Text Document'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Microsoft Word 2007-2013 XML
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text (Transitional)
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Word 2007–365
'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'text/html'
,
'HTML Document (Writer)'
),
(
'text/plain'
,
'Text - Choose Encoding'
)]
self
.
assertEqual
(
get
(
"text/plain;ignored=param"
),
text_plain_output_list
)
...
...
@@ -219,15 +221,17 @@ class TestHandler(HandlerTestCase):
"""Test allowed conversion format for application/msword"""
self
.
assertEqual
(
sorted
(
Handler
.
getAllowedConversionFormatList
(
"application/msword;ignored=param"
)),
[
(
'application/msword'
,
'Microsoft Word 97-2003'
),
[
(
'application/epub+zip'
,
'EPUB Document'
),
(
'application/msword'
,
'Word 97–2003'
),
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/rtf'
,
'Rich Text'
),
(
'application/vnd.ms-word.document.macroEnabled.12'
,
'Word 2007–365 VBA'
),
(
'application/vnd.oasis.opendocument.text'
,
'ODF Text Document'
),
(
'application/vnd.oasis.opendocument.text-flat-xml'
,
'Flat XML ODF Text Document'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Microsoft Word 2007-2013 XML
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text (Transitional)
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Word 2007–365
'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'text/html'
,
'HTML Document (Writer)'
),
(
'text/plain'
,
'Text - Choose Encoding'
)
])
...
...
@@ -238,12 +242,16 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
...
...
@@ -261,15 +269,17 @@ class TestHandler(HandlerTestCase):
):
self
.
assertEqual
(
sorted
(
Handler
.
getAllowedConversionFormatList
(
content_type
)),
[
(
'application/msword'
,
'Microsoft Word 97-2003'
),
(
'application/epub+zip'
,
'EPUB Document'
),
(
'application/msword'
,
'Word 97–2003'
),
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/rtf'
,
'Rich Text'
),
(
'application/vnd.ms-word.document.macroEnabled.12'
,
'Word 2007–365 VBA'
),
(
'application/vnd.oasis.opendocument.text'
,
'ODF Text Document'
),
(
'application/vnd.oasis.opendocument.text-flat-xml'
,
'Flat XML ODF Text Document'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Microsoft Word 2007-2013 XML
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text (Transitional)
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Word 2007–365
'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'text/html'
,
'HTML Document (Writer)'
),
(
'text/plain'
,
'Text - Choose Encoding'
),
])
...
...
@@ -278,15 +288,17 @@ class TestHandler(HandlerTestCase):
"""Test allowed conversion format for application/vnd.openxmlformats-officedocument.wordprocessingml.document"""
self
.
assertEqual
(
sorted
(
Handler
.
getAllowedConversionFormatList
(
"application/vnd.openxmlformats-officedocument.wordprocessingml.document;ignored=param"
)),
[
(
'application/msword'
,
'Microsoft Word 97-2003'
),
[
(
'application/epub+zip'
,
'EPUB Document'
),
(
'application/msword'
,
'Word 97–2003'
),
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/rtf'
,
'Rich Text'
),
(
'application/vnd.ms-word.document.macroEnabled.12'
,
'Word 2007–365 VBA'
),
(
'application/vnd.oasis.opendocument.text'
,
'ODF Text Document'
),
(
'application/vnd.oasis.opendocument.text-flat-xml'
,
'Flat XML ODF Text Document'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Microsoft Word 2007-2013 XML
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text (Transitional)
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Word 2007–365
'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'text/html'
,
'HTML Document (Writer)'
),
(
'text/plain'
,
'Text - Choose Encoding'
)
])
...
...
@@ -297,12 +309,16 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
...
...
@@ -313,12 +329,16 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
...
...
@@ -326,23 +346,25 @@ class TestHandler(HandlerTestCase):
"""Test allowed conversion format for text/html"""
self
.
assertEqual
(
sorted
(
Handler
.
getAllowedConversionFormatList
(
"text/html;ignored=param"
)),
[
(
'application/msword'
,
'Microsoft Word 97-2003'
),
[
(
'application/epub+zip'
,
'EPUB Document'
),
(
'application/msword'
,
'Word 97–2003'
),
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/rtf'
,
'Rich Text'
),
(
'application/vnd.ms-excel'
,
'Microsoft Excel 97-2003'
),
(
'application/vnd.ms-excel.sheet.macroEnabled.12'
,
'Microsoft Excel 2007-2016 XML (macro enabled)'
),
(
'application/vnd.ms-excel'
,
'Excel 97–2003'
),
(
'application/vnd.ms-excel.sheet.macroEnabled.12'
,
'Excel 2007–365 (macro-enabled)'
),
(
'application/vnd.ms-word.document.macroEnabled.12'
,
'Word 2007–365 VBA'
),
(
'application/vnd.oasis.opendocument.spreadsheet'
,
'ODF Spreadsheet'
),
(
'application/vnd.oasis.opendocument.spreadsheet-flat-xml'
,
u
'Flat XML ODF Spreadsheet'
),
(
'application/vnd.oasis.opendocument.spreadsheet-flat-xml'
,
'Flat XML ODF Spreadsheet'
),
(
'application/vnd.oasis.opendocument.text'
,
'ODF Text Document'
),
(
'application/vnd.oasis.opendocument.text'
,
'Text (Writer/Web)'
),
(
'application/vnd.oasis.opendocument.text-flat-xml'
,
'Flat XML ODF Text Document'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'
Microsoft Excel 2007-2013 XML
'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'
Excel 2007–365
'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'Office Open XML Spreadsheet'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Microsoft Word 2007-2013 XML
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text (Transitional)
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Word 2007–365
'
),
(
'application/vnd.sun.xml.writer'
,
'OpenOffice.org 1.0 Text Document (Writer/Web)'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'text/csv'
,
'Text CSV'
),
(
'text/html'
,
'HTML Document'
),
(
'text/html'
,
'HTML Document (Calc)'
),
...
...
@@ -358,12 +380,16 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
...
...
@@ -374,12 +400,16 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
...
...
@@ -390,12 +420,16 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
...
...
@@ -403,17 +437,31 @@ class TestHandler(HandlerTestCase):
"""Test allowed conversion format for image/svg+xml"""
self
.
assertEqual
(
sorted
(
Handler
.
getAllowedConversionFormatList
(
"image/svg+xml;ignored=param"
)),
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
[(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.ms-powerpoint'
,
'PowerPoint 97–2003'
),
(
'application/vnd.ms-powerpoint'
,
'PowerPoint 97–2003 AutoPlay'
),
(
'application/vnd.ms-powerpoint.presentation.macroEnabled.12'
,
'PowerPoint 2007–365 VBA'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.presentation'
,
'ODF Presentation'
),
(
'application/vnd.oasis.opendocument.presentation-flat-xml'
,
'Flat XML ODF Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
,
'Office Open XML Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
,
'PowerPoint 2007–365'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
,
'Office Open XML Presentation AutoPlay'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
,
'PowerPoint 2007–365 AutoPlay'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphics'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
),
(
'text/html'
,
'HTML Document (Impress)'
)
])
def
testGetAllowedConversionFormatList_ImageTiff
(
self
):
"""Test allowed conversion format for image/tiff"""
...
...
@@ -422,14 +470,18 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
(
'text/html'
,
'HTML Document (Draw)'
)])
def
testGetAllowedConversionFormatList_ImageXCmuRaster
(
self
):
"""Test allowed conversion format for image/x-cmu-raster"""
...
...
@@ -438,12 +490,16 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
...
...
@@ -454,12 +510,16 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
...
...
@@ -470,12 +530,16 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
...
...
@@ -486,12 +550,16 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
...
...
@@ -502,12 +570,16 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
...
...
@@ -518,12 +590,16 @@ class TestHandler(HandlerTestCase):
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.oasis.opendocument.graphics'
,
'ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
u'Flat XML ODF Drawing'
),
(
'application/vnd.oasis.opendocument.graphics-flat-xml'
,
'Flat XML ODF Drawing'
),
(
'application/x-ms-wmz'
,
'WMZ - Compressed Windows Metafile'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/svg+xml'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Draw)'
)
])
...
...
@@ -532,13 +608,14 @@ class TestHandler(HandlerTestCase):
self
.
assertEqual
(
sorted
(
Handler
.
getAllowedConversionFormatList
(
"application/vnd.ms-excel;ignored=param"
)),
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/vnd.ms-excel'
,
'
Microsoft Excel 97-
2003'
),
(
'application/vnd.ms-excel.sheet.macroEnabled.12'
,
'
Microsoft Excel 2007-2016 XML (macro
enabled)'
),
(
'application/vnd.ms-excel'
,
'
Excel 97–
2003'
),
(
'application/vnd.ms-excel.sheet.macroEnabled.12'
,
'
Excel 2007–365 (macro-
enabled)'
),
(
'application/vnd.oasis.opendocument.spreadsheet'
,
'ODF Spreadsheet'
),
(
'application/vnd.oasis.opendocument.spreadsheet-flat-xml'
,
u
'Flat XML ODF Spreadsheet'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'
Microsoft Excel 2007-2013 XML
'
),
(
'application/vnd.oasis.opendocument.spreadsheet-flat-xml'
,
'Flat XML ODF Spreadsheet'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'
Excel 2007–365
'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'Office Open XML Spreadsheet'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphics'
),
(
'text/csv'
,
'Text CSV'
),
(
'text/html'
,
'HTML Document (Calc)'
)
])
...
...
@@ -553,13 +630,14 @@ class TestHandler(HandlerTestCase):
self
.
assertEqual
(
sorted
(
Handler
.
getAllowedConversionFormatList
(
"application/vnd.oasis.opendocument.spreadsheet;ignored=param"
)),
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/vnd.ms-excel'
,
'
Microsoft Excel 97-
2003'
),
(
'application/vnd.ms-excel.sheet.macroEnabled.12'
,
'
Microsoft Excel 2007-2016 XML (macro
enabled)'
),
(
'application/vnd.ms-excel'
,
'
Excel 97–
2003'
),
(
'application/vnd.ms-excel.sheet.macroEnabled.12'
,
'
Excel 2007–365 (macro-
enabled)'
),
(
'application/vnd.oasis.opendocument.spreadsheet'
,
'ODF Spreadsheet'
),
(
'application/vnd.oasis.opendocument.spreadsheet-flat-xml'
,
u
'Flat XML ODF Spreadsheet'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'
Microsoft Excel 2007-2013 XML
'
),
(
'application/vnd.oasis.opendocument.spreadsheet-flat-xml'
,
'Flat XML ODF Spreadsheet'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'
Excel 2007–365
'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'Office Open XML Spreadsheet'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphics'
),
(
'text/csv'
,
'Text CSV'
),
(
'text/html'
,
'HTML Document (Calc)'
)
])
...
...
@@ -568,13 +646,14 @@ class TestHandler(HandlerTestCase):
self
.
assertEqual
(
sorted
(
Handler
.
getAllowedConversionFormatList
(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;ignored=param"
)),
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/vnd.ms-excel'
,
'
Microsoft Excel 97-
2003'
),
(
'application/vnd.ms-excel.sheet.macroEnabled.12'
,
'
Microsoft Excel 2007-2016 XML (macro
enabled)'
),
(
'application/vnd.ms-excel'
,
'
Excel 97–
2003'
),
(
'application/vnd.ms-excel.sheet.macroEnabled.12'
,
'
Excel 2007–365 (macro-
enabled)'
),
(
'application/vnd.oasis.opendocument.spreadsheet'
,
'ODF Spreadsheet'
),
(
'application/vnd.oasis.opendocument.spreadsheet-flat-xml'
,
u
'Flat XML ODF Spreadsheet'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'
Microsoft Excel 2007-2013 XML
'
),
(
'application/vnd.oasis.opendocument.spreadsheet-flat-xml'
,
'Flat XML ODF Spreadsheet'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'
Excel 2007–365
'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'Office Open XML Spreadsheet'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphics'
),
(
'text/csv'
,
'Text CSV'
),
(
'text/html'
,
'HTML Document (Calc)'
)
])
...
...
@@ -582,15 +661,17 @@ class TestHandler(HandlerTestCase):
"""Test allowed conversion format for application/vnd.sun.xml.writer"""
self
.
assertEqual
(
sorted
(
Handler
.
getAllowedConversionFormatList
(
"application/vnd.sun.xml.writer;ignored=param"
)),
[
(
'application/msword'
,
'Microsoft Word 97-2003'
),
[
(
'application/epub+zip'
,
'EPUB Document'
),
(
'application/msword'
,
'Word 97–2003'
),
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/rtf'
,
'Rich Text'
),
(
'application/vnd.ms-word.document.macroEnabled.12'
,
'Word 2007–365 VBA'
),
(
'application/vnd.oasis.opendocument.text'
,
'ODF Text Document'
),
(
'application/vnd.oasis.opendocument.text-flat-xml'
,
'Flat XML ODF Text Document'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Microsoft Word 2007-2013 XML
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text (Transitional)
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Word 2007–365
'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'text/html'
,
'HTML Document (Writer)'
),
(
'text/plain'
,
'Text - Choose Encoding'
)
])
...
...
@@ -598,23 +679,25 @@ class TestHandler(HandlerTestCase):
"""Test allowed conversion format for text/csv"""
self
.
assertEqual
(
sorted
(
Handler
.
getAllowedConversionFormatList
(
"text/csv;ignored=param"
)),
[
(
'application/msword'
,
'Microsoft Word 97-2003'
),
[
(
'application/epub+zip'
,
'EPUB Document'
),
(
'application/msword'
,
'Word 97–2003'
),
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/rtf'
,
'Rich Text'
),
(
'application/vnd.ms-excel'
,
'Microsoft Excel 97-2003'
),
(
'application/vnd.ms-excel.sheet.macroEnabled.12'
,
'Microsoft Excel 2007-2016 XML (macro enabled)'
),
(
'application/vnd.ms-excel'
,
'Excel 97–2003'
),
(
'application/vnd.ms-excel.sheet.macroEnabled.12'
,
'Excel 2007–365 (macro-enabled)'
),
(
'application/vnd.ms-word.document.macroEnabled.12'
,
'Word 2007–365 VBA'
),
(
'application/vnd.oasis.opendocument.spreadsheet'
,
'ODF Spreadsheet'
),
(
'application/vnd.oasis.opendocument.spreadsheet-flat-xml'
,
u
'Flat XML ODF Spreadsheet'
),
(
'application/vnd.oasis.opendocument.spreadsheet-flat-xml'
,
'Flat XML ODF Spreadsheet'
),
(
'application/vnd.oasis.opendocument.text'
,
'ODF Text Document'
),
(
'application/vnd.oasis.opendocument.text'
,
'Text (Writer/Web)'
),
(
'application/vnd.oasis.opendocument.text-flat-xml'
,
'Flat XML ODF Text Document'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'
Microsoft Excel 2007-2013 XML
'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'
Excel 2007–365
'
),
(
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'Office Open XML Spreadsheet'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Microsoft Word 2007-2013 XML
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Office Open XML Text (Transitional)
'
),
(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
,
'
Word 2007–365
'
),
(
'application/vnd.sun.xml.writer'
,
'OpenOffice.org 1.0 Text Document (Writer/Web)'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'text/csv'
,
'Text CSV'
),
(
'text/html'
,
'HTML Document'
),
(
'text/html'
,
'HTML Document (Calc)'
),
...
...
@@ -629,20 +712,22 @@ class TestHandler(HandlerTestCase):
sorted
(
Handler
.
getAllowedConversionFormatList
(
"application/vnd.oasis.opendocument.presentation;ignored=param"
)),
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.ms-powerpoint'
,
'
Microsoft PowerPoint 97-
2003'
),
(
'application/vnd.ms-powerpoint'
,
'
Microsoft PowerPoint 97-
2003 AutoPlay'
),
(
'application/vnd.
oasis.opendocument.graphics'
,
'ODF Drawing (Impress)
'
),
(
'application/vnd.ms-powerpoint'
,
'
PowerPoint 97–
2003'
),
(
'application/vnd.ms-powerpoint'
,
'
PowerPoint 97–
2003 AutoPlay'
),
(
'application/vnd.
ms-powerpoint.presentation.macroEnabled.12'
,
'PowerPoint 2007–365 VBA
'
),
(
'application/vnd.oasis.opendocument.presentation'
,
'ODF Presentation'
),
(
'application/vnd.oasis.opendocument.presentation-flat-xml'
,
u'Flat XML ODF Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
,
'Microsoft PowerPoint 2007-2013 XML'
),
(
'application/vnd.oasis.opendocument.presentation-flat-xml'
,
'Flat XML ODF Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
,
'Office Open XML Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.
slideshow'
,
'Microsoft PowerPoint 2007-2013 XML AutoPlay'
),
# TEST it
(
'application/vnd.openxmlformats-officedocument.presentationml.
presentation'
,
'PowerPoint 2007–365'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
,
'Office Open XML Presentation AutoPlay'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
,
'PowerPoint 2007–365 AutoPlay'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Impress)'
)
])
...
...
@@ -652,20 +737,22 @@ class TestHandler(HandlerTestCase):
sorted
(
Handler
.
getAllowedConversionFormatList
(
"application/vnd.openxmlformats-officedocument.presentationml.presentation;ignored=param"
)),
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.ms-powerpoint'
,
'
Microsoft PowerPoint 97-
2003'
),
(
'application/vnd.ms-powerpoint'
,
'
Microsoft PowerPoint 97-
2003 AutoPlay'
),
(
'application/vnd.
oasis.opendocument.graphics'
,
'ODF Drawing (Impress)
'
),
(
'application/vnd.ms-powerpoint'
,
'
PowerPoint 97–
2003'
),
(
'application/vnd.ms-powerpoint'
,
'
PowerPoint 97–
2003 AutoPlay'
),
(
'application/vnd.
ms-powerpoint.presentation.macroEnabled.12'
,
'PowerPoint 2007–365 VBA
'
),
(
'application/vnd.oasis.opendocument.presentation'
,
'ODF Presentation'
),
(
'application/vnd.oasis.opendocument.presentation-flat-xml'
,
u'Flat XML ODF Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
,
'Microsoft PowerPoint 2007-2013 XML'
),
(
'application/vnd.oasis.opendocument.presentation-flat-xml'
,
'Flat XML ODF Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
,
'Office Open XML Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.
slideshow'
,
'Microsoft PowerPoint 2007-2013 XML AutoPlay
'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.
presentation'
,
'PowerPoint 2007–365
'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
,
'Office Open XML Presentation AutoPlay'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
,
'PowerPoint 2007–365 AutoPlay'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Impress)'
)
])
...
...
@@ -675,20 +762,22 @@ class TestHandler(HandlerTestCase):
sorted
(
Handler
.
getAllowedConversionFormatList
(
"application/vnd.openxmlformats-officedocument.presentationml.slideshow;ignored=param"
)),
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.ms-powerpoint'
,
'
Microsoft PowerPoint 97-
2003'
),
(
'application/vnd.ms-powerpoint'
,
'
Microsoft PowerPoint 97-
2003 AutoPlay'
),
(
'application/vnd.
oasis.opendocument.graphics'
,
'ODF Drawing (Impress)
'
),
(
'application/vnd.ms-powerpoint'
,
'
PowerPoint 97–
2003'
),
(
'application/vnd.ms-powerpoint'
,
'
PowerPoint 97–
2003 AutoPlay'
),
(
'application/vnd.
ms-powerpoint.presentation.macroEnabled.12'
,
'PowerPoint 2007–365 VBA
'
),
(
'application/vnd.oasis.opendocument.presentation'
,
'ODF Presentation'
),
(
'application/vnd.oasis.opendocument.presentation-flat-xml'
,
u'Flat XML ODF Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
,
'Microsoft PowerPoint 2007-2013 XML'
),
(
'application/vnd.oasis.opendocument.presentation-flat-xml'
,
'Flat XML ODF Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
,
'Office Open XML Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.
slideshow'
,
'Microsoft PowerPoint 2007-2013 XML AutoPlay
'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.
presentation'
,
'PowerPoint 2007–365
'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
,
'Office Open XML Presentation AutoPlay'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
,
'PowerPoint 2007–365 AutoPlay'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Impress)'
)
])
...
...
@@ -698,20 +787,21 @@ class TestHandler(HandlerTestCase):
sorted
(
Handler
.
getAllowedConversionFormatList
(
"application/vnd.ms-powerpoint;ignored=param"
)),
[
(
'application/pdf'
,
'PDF - Portable Document Format'
),
(
'application/postscript'
,
'EPS - Encapsulated PostScript'
),
(
'application/vnd.ms-powerpoint'
,
'
Microsoft PowerPoint 97-
2003'
),
(
'application/vnd.ms-powerpoint'
,
'
Microsoft PowerPoint 97-
2003 AutoPlay'
),
(
'application/vnd.
oasis.opendocument.graphics'
,
'ODF Drawing (Impress)
'
),
(
'application/vnd.ms-powerpoint'
,
'
PowerPoint 97–
2003'
),
(
'application/vnd.ms-powerpoint'
,
'
PowerPoint 97–
2003 AutoPlay'
),
(
'application/vnd.
ms-powerpoint.presentation.macroEnabled.12'
,
'PowerPoint 2007–365 VBA
'
),
(
'application/vnd.oasis.opendocument.presentation'
,
'ODF Presentation'
),
(
'application/vnd.oasis.opendocument.presentation-flat-xml'
,
u'Flat XML ODF Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
,
'Microsoft PowerPoint 2007-2013 XML'
),
(
'application/vnd.oasis.opendocument.presentation-flat-xml'
,
'Flat XML ODF Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
,
'Office Open XML Presentation'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.
slideshow'
,
'Microsoft PowerPoint 2007-2013 XML AutoPlay
'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.
presentation'
,
'PowerPoint 2007–365
'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
,
'Office Open XML Presentation AutoPlay'
),
(
'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
,
'PowerPoint 2007–365 AutoPlay'
),
(
'image/emf'
,
'EMF - Enhanced Metafile'
),
(
'image/gif'
,
'GIF - Graphics Interchange Format'
),
(
'image/jpeg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'image/png'
,
'PNG - Portable Network Graphic'
),
(
'image/png'
,
'PNG - Portable Network Graphic
s
'
),
(
'image/svg+xml'
,
'SVG - Scalable Vector Graphics'
),
(
'image/tiff'
,
'TIFF - Tagged Image File Format'
),
(
'image/wmf'
,
'WMF - Windows Metafile'
),
(
'image/x-ms-bmp'
,
'BMP - Windows Bitmap'
),
(
'text/html'
,
'HTML Document (Impress)'
)
])
cloudooo/handler/ooo/tests/testOooMimemapper.py
View file @
72da57bf
...
...
@@ -32,19 +32,26 @@ from cloudooo.tests.handlerTestCase import HandlerTestCase
from
cloudooo.handler.ooo.application.openoffice
import
openoffice
from
cloudooo.handler.ooo.mimemapper
import
MimeMapper
# XXX depending on wether allowed targets are evaluated by mime or by
# extension/document_type, the returned mime types are different for text
text_expected_tuple
=
(
(
'doc'
,
'
Microsoft Word 97-
2003'
),
(
'
ms.docx'
,
'Microsoft Word 2007-2013 XML
'
),
(
'
docx'
,
'Office Open XML Tex
t'
),
(
'doc'
,
'
Word 97–
2003'
),
(
'
docx'
,
'Office Open XML Text (Transitional)
'
),
(
'
epub'
,
'EPUB Documen
t'
),
(
'fodt'
,
'Flat XML ODF Text Document'
),
(
'html'
,
'HTML Document (Writer)'
),
(
'jpg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'ms.docx'
,
'Word 2007–365'
),
(
'odt'
,
'ODF Text Document'
),
(
'pdf'
,
'PDF - Portable Document Format'
),
(
'png'
,
'PNG - Portable Network Graphic'
),
(
'png'
,
'PNG - Portable Network Graphic
s
'
),
(
'rtf'
,
'Rich Text'
),
(
'txt'
,
'Text - Choose Encoding'
),
)
extra_text_expected_tuple
=
(
(
'docm'
,
'Word 2007–365 VBA'
),
(
'webp'
,
'WEBP - WebP Image'
),
)
global_expected_tuple
=
(
)
...
...
@@ -52,33 +59,27 @@ global_expected_tuple = (
drawing_expected_tuple
=
(
(
'bmp'
,
'BMP - Windows Bitmap'
),
(
'emf'
,
'EMF - Enhanced Metafile'
),
(
'emz'
,
'EMZ - Compressed Enhanced Metafile'
),
(
'eps'
,
'EPS - Encapsulated PostScript'
),
(
'fodg'
,
'Flat XML ODF Drawing'
),
(
'gif'
,
'GIF - Graphics Interchange Format'
),
(
'html'
,
'HTML Document (Draw)'
),
(
'jpg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'met'
,
'MET - OS/2 Metafile'
),
(
'odg'
,
'ODF Drawing'
),
(
'pbm'
,
'PBM - Portable Bitmap'
),
(
'pct'
,
'PCT - Mac Pict'
),
(
'pdf'
,
'PDF - Portable Document Format'
),
(
'pgm'
,
'PGM - Portable Graymap'
),
(
'png'
,
'PNG - Portable Network Graphic'
),
(
'ppm'
,
'PPM - Portable Pixelmap'
),
(
'ras'
,
'RAS - Sun Raster Image'
),
(
'png'
,
'PNG - Portable Network Graphics'
),
(
'svg'
,
'SVG - Scalable Vector Graphics'
),
(
'svm'
,
'SVM - StarView Metafile'
),
(
'tif'
,
'TIFF - Tagged Image File Format'
),
(
'svgz'
,
'SVGZ - Compressed Scalable Vector Graphics'
),
(
'tiff'
,
'TIFF - Tagged Image File Format'
),
(
'webp'
,
'WEBP - WebP Image'
),
(
'wmf'
,
'WMF - Windows Metafile'
),
(
'
xpm'
,
'XPM - X PixMap
'
),
(
'
wmz'
,
'WMZ - Compressed Windows Metafile
'
),
)
web_expected_tuple
=
(
(
'html'
,
'HTML Document'
),
(
'jpg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'odt'
,
'Text (Writer/Web)'
),
(
'pdf'
,
'PDF - Portable Document Format'
),
(
'png'
,
'PNG - Portable Network Graphic'
),
(
'sxw'
,
'OpenOffice.org 1.0 Text Document (Writer/Web)'
),
(
'txt'
,
'Text (Writer/Web)'
),
(
'txt'
,
'Text - Choose Encoding (Writer/Web)'
),
...
...
@@ -92,40 +93,35 @@ presentation_expected_tuple = (
(
'gif'
,
'GIF - Graphics Interchange Format'
),
(
'html'
,
'HTML Document (Impress)'
),
(
'jpg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'met'
,
'MET - OS/2 Metafile'
),
(
'odg'
,
'ODF Drawing (Impress)'
),
(
'odp'
,
'ODF Presentation'
),
(
'pbm'
,
'PBM - Portable Bitmap'
),
(
'pct'
,
'PCT - Mac Pict'
),
(
'pdf'
,
'PDF - Portable Document Format'
),
(
'pgm'
,
'PGM - Portable Graymap'
),
(
'png'
,
'PNG - Portable Network Graphic'
),
(
'ppm'
,
'PPM - Portable Pixelmap'
),
(
'pps'
,
'Microsoft PowerPoint 97-2003 AutoPlay'
),
(
'ms.ppsx'
,
'Microsoft PowerPoint 2007-2013 XML AutoPlay'
),
(
'png'
,
'PNG - Portable Network Graphics'
),
(
'pps'
,
'PowerPoint 97–2003 AutoPlay'
),
(
'ppsx'
,
'Office Open XML Presentation AutoPlay'
),
(
'ppt'
,
'Microsoft PowerPoint 97-2003'
),
(
'ms.pptx'
,
'Microsoft PowerPoint 2007-2013 XML'
),
(
'ppsx'
,
'PowerPoint 2007–365 AutoPlay'
),
(
'ppt'
,
'PowerPoint 97–2003'
),
(
'pptm'
,
'PowerPoint 2007–365 VBA'
),
(
'pptx'
,
'Office Open XML Presentation'
),
(
'
ras'
,
'RAS - Sun Raster Image
'
),
(
'
pptx'
,
'PowerPoint 2007–365
'
),
(
'svg'
,
'SVG - Scalable Vector Graphics'
),
(
'
svm'
,
'SVM - StarView Metafile
'
),
(
'
tif'
,
'TIFF - Tagged Image File Format
'
),
(
'
tiff'
,
'TIFF - Tagged Image File Format
'
),
(
'
webp'
,
'WEBP - WebP Image
'
),
(
'wmf'
,
'WMF - Windows Metafile'
),
(
'xpm'
,
'XPM - X PixMap'
),
)
spreadsheet_expected_tuple
=
(
(
'csv'
,
'Text CSV'
),
(
'fods'
,
'Flat XML ODF Spreadsheet'
),
(
'html'
,
'HTML Document (Calc)'
),
(
'jpg'
,
'JPEG - Joint Photographic Experts Group'
),
(
'ods'
,
'ODF Spreadsheet'
),
(
'pdf'
,
'PDF - Portable Document Format'
),
(
'png'
,
'PNG - Portable Network Graphic'
),
(
'png'
,
'PNG - Portable Network Graphic
s
'
),
(
'slk'
,
'SYLK'
),
(
'xls'
,
'Microsoft Excel 97-2003'
),
(
'xlsm'
,
'Microsoft Excel 2007-2016 XML (macro enabled)'
),
(
'ms.xlsx'
,
'Microsoft Excel 2007-2013 XML'
),
(
'webp'
,
'WEBP - WebP Image'
),
(
'xls'
,
'Excel 97–2003'
),
(
'ms.xlsx'
,
'Excel 2007–365'
),
(
'xlsm'
,
'Excel 2007–365 (macro-enabled)'
),
(
'xlsx'
,
'Office Open XML Spreadsheet'
),
)
...
...
@@ -138,9 +134,6 @@ math_expected_tuple = (
(
'smf'
,
'StarMath 5.0'
),
)
chart_expected_tuple
=
(
(
'odc'
,
'ODF Chart'
),
)
OPENOFFICE
=
True
...
...
@@ -195,8 +188,6 @@ class TestMimeMapper(HandlerTestCase):
document_type_dict
=
self
.
mimemapper
.
_document_type_dict
type
=
document_type_dict
.
get
(
"text"
)
self
.
assertEqual
(
type
,
'com.sun.star.text.TextDocument'
)
type
=
document_type_dict
.
get
(
"chart"
)
self
.
assertEqual
(
type
,
'com.sun.star.chart2.ChartDocument'
)
type
=
document_type_dict
.
get
(
"drawing"
)
self
.
assertEqual
(
type
,
'com.sun.star.drawing.DrawingDocument'
)
type
=
document_type_dict
.
get
(
"presentation"
)
...
...
@@ -210,87 +201,68 @@ class TestMimeMapper(HandlerTestCase):
"""Test if function getAllowedExtensionList returns correctly a list with
extensions that can generate with extension passed."""
doc_got_list
=
list
(
self
.
mimemapper
.
getAllowedExtensionList
(
'doc'
))
_text_expected_tuple
=
text_expected_tuple
+
extra_text_expected_tuple
for
arg
in
doc_got_list
:
self
.
assertTrue
(
arg
in
text_expected_tuple
,
"%s not in %s"
%
(
arg
,
text_expected_tuple
))
self
.
assertIn
(
arg
,
_text_expected_tuple
)
jpeg_got_list
=
list
(
self
.
mimemapper
.
getAllowedExtensionList
(
'jpeg'
))
jpeg_expected_list
=
list
(
set
(
presentation_expected_tuple
+
drawing_expected_tuple
))
for
arg
in
jpeg_got_list
:
self
.
assertTrue
(
arg
in
jpeg_expected_list
,
"%s not in %s"
%
(
arg
,
jpeg_expected_list
))
self
.
assertIn
(
arg
,
jpeg_expected_list
)
pdf_got_list
=
list
(
self
.
mimemapper
.
getAllowedExtensionList
(
'pdf'
))
pdf_expected_list
=
list
(
set
(
presentation_expected_tuple
+
drawing_expected_tuple
+
web_expected_tuple
+
global_expected_tuple
+
math_expected_tuple
+
text_expected_tuple
+
spreadsheet_expected_tuple
))
math_expected_tuple
+
_
text_expected_tuple
+
spreadsheet_expected_tuple
))
for
arg
in
pdf_got_list
:
self
.
assertTrue
(
arg
in
pdf_expected_list
,
"%s not in %s"
%
(
arg
,
pdf_expected_list
))
self
.
assertIn
(
arg
,
pdf_expected_list
)
def
testGetAllowedExtensionListForText
(
self
):
"""Passing document_type equal to 'text', the return must be equal
to text_expected_tuple."""
got_list
=
list
(
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'text'
))
text_expected_list
=
list
(
text_expected_tuple
)
for
arg
in
got_list
:
self
.
assertTrue
(
arg
in
text_expected_list
,
"%s not in %s"
%
(
arg
,
text_expected_list
))
self
.
assertEqual
(
sorted
(
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'text'
)),
sorted
(
text_expected_tuple
+
extra_text_expected_tuple
)
)
def
testGetAllowedExtensionListForGlobal
(
self
):
"""Passing document_type equal to 'global', the return must be equal
to global_expected_tuple."""
got_list
=
list
(
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'global'
))
got_list
.
sort
()
global_expected_list
=
list
(
global_expected_tuple
)
global_expected_list
.
sort
()
self
.
assertEqual
(
got_list
,
global_expected_list
)
self
.
assertEqual
(
sorted
(
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'global'
)),
sorted
(
global_expected_tuple
)
)
def
testGetAllAllowedExtensionListForDrawing
(
self
):
"""Passing document_type equal to 'drawing', the return must be equal
to drawing_expected_tuple."""
got_list
=
list
(
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'drawing'
))
drawing_expected_list
=
list
(
drawing_expected_tuple
)
drawing_expected_list
.
sort
()
for
arg
in
got_list
:
self
.
assertTrue
(
arg
in
drawing_expected_list
,
"%s not in %s"
%
(
arg
,
drawing_expected_list
))
self
.
assertEqual
(
sorted
(
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'drawing'
)),
sorted
(
drawing_expected_tuple
)
)
def
testGetAllAllowedExtensionListForWeb
(
self
):
"""Passing document_type equal to 'web', the return must be equal
to web_expected_tuple."""
got_tuple
=
list
(
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'web'
))
got_tuple
.
sort
()
web_expected_list
=
list
(
web_expected_tuple
)
web_expected_list
.
sort
()
self
.
assertEqual
(
got_tuple
,
web_expected_list
)
self
.
assertEqual
(
sorted
(
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'web'
)),
sorted
(
web_expected_tuple
)
)
def
testGetAllAllowedExtensionListForPresentation
(
self
):
"""Passing document_type equal to 'presentation', the return must be equal
to presentation_expected_tuple."""
got_list
=
\
list
(
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'presentation'
))
presentation_expected_list
=
list
(
presentation_expected_tuple
)
presentation_expected_list
.
sort
()
for
arg
in
got_list
:
self
.
assertTrue
(
arg
in
presentation_expected_list
,
"%s not in %s"
%
(
arg
,
presentation_expected_list
))
self
.
assertEqual
(
sorted
(
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'presentation'
)),
sorted
(
presentation_expected_tuple
)
)
def
testGetAllAllowedExtensionListForSpreadsheet
(
self
):
"""Passing document_type equal to 'spreadsheet', the return must be equal
to spreadsheet_expected_tuple."""
got_list
=
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'spreadsheet'
)
for
arg
in
got_list
:
self
.
assertTrue
(
arg
in
spreadsheet_expected_tuple
,
"%s not in %s"
%
(
arg
,
spreadsheet_expected_tuple
))
def
testGetAllAllowedExtensionListForChart
(
self
):
"""Passing document_type equal to 'chart', the return must be equal
to chart_expected_tuple."""
got_list
=
list
(
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'chart'
))
got_list
.
sort
()
chart_expected_list
=
list
(
chart_expected_tuple
)
chart_expected_list
.
sort
()
self
.
assertEqual
(
got_list
,
chart_expected_list
)
self
.
assertEqual
(
sorted
(
self
.
mimemapper
.
getAllowedExtensionList
(
document_type
=
'spreadsheet'
)),
sorted
(
spreadsheet_expected_tuple
)
)
def
testGetFilterName
(
self
):
"""Test if passing extension and document_type, the filter is correct."""
...
...
cloudooo/handler/ooo/tests/testOooServer.py
View file @
72da57bf
...
...
@@ -49,9 +49,14 @@ class TestAllowedExtensions(TestCase):
ui_name. The request is by document type as text"""
text_request
=
{
'document_type'
:
"text"
}
text_allowed_list
=
self
.
proxy
.
getAllowedExtensionList
(
text_request
)
# XXX slightly different allowed formats with document_type !?
_text_expected_tuple
=
text_expected_tuple
+
(
(
'docm'
,
'Word 2007–365 VBA'
),
(
'webp'
,
'WEBP - WebP Image'
),
)
self
.
assertEqual
(
sorted
([
tuple
(
x
)
for
x
in
text_allowed_list
]),
sorted
(
text_expected_tuple
))
sorted
([
tuple
(
x
)
for
x
in
text_allowed_list
]),
sorted
(
_
text_expected_tuple
))
def
testGetAllowedPresentationExtensionListByType
(
self
):
"""Verify if getAllowedExtensionList returns is a list with extension and
...
...
@@ -59,14 +64,17 @@ class TestAllowedExtensions(TestCase):
request_dict
=
{
'document_type'
:
"presentation"
}
presentation_allowed_list
=
self
.
proxy
.
getAllowedExtensionList
(
request_dict
)
self
.
assertTrue
(
presentation_allowed_list
)
for
arg
in
presentation_allowed_list
:
self
.
assertIn
(
tuple
(
arg
),
presentation_expected_tuple
)
self
.
assertEqual
(
sorted
([
tuple
(
x
)
for
x
in
presentation_allowed_list
]),
sorted
(
presentation_expected_tuple
))
def
testGetAllowedExtensionListByExtension
(
self
):
"""Verify if getAllowedExtensionList returns is a list with extension and
ui_name. The request is by extension"""
doc_allowed_list
=
self
.
proxy
.
getAllowedExtensionList
({
'extension'
:
"doc"
})
self
.
assertEqual
(
sorted
([
tuple
(
x
)
for
x
in
doc_allowed_list
]),
sorted
(
text_expected_tuple
))
self
.
assertEqual
(
sorted
([
tuple
(
x
)
for
x
in
doc_allowed_list
]),
sorted
(
text_expected_tuple
))
def
testGetAllowedExtensionListByMimetype
(
self
):
"""Verify if getAllowedExtensionList returns is a list with extension and
...
...
cloudooo/handler/ooo/tests/testOooUnoMimemapper.py
View file @
72da57bf
...
...
@@ -99,7 +99,7 @@ class TestUnoMimeMapper(HandlerTestCase):
def
testWithoutOpenOffice
(
self
):
"""Test when the openoffice is stopped"""
error_msg
=
"couldn
\
'
t connect to socket
(Success)
\
n
"
error_msg
=
"couldn
\
'
t connect to socket"
hostname
,
host
=
openoffice
.
getAddress
()
openoffice
.
stop
()
python
=
path
.
join
(
self
.
office_binary_path
,
"python"
)
...
...
cloudooo/manager.py
View file @
72da57bf
...
...
@@ -80,9 +80,11 @@ def BBB_guess_extension(mimetype, title=None):
"Flat XML ODF Text Document"
:
".fodt"
,
"MET - OS/2 Metafile"
:
".met"
,
"Microsoft Excel 2007-2013 XML"
:
".ms.xlsx"
,
"Excel 2007–365"
:
".ms.xlsx"
,
"Microsoft PowerPoint 2007-2013 XML"
:
".ms.pptx"
,
"Microsoft PowerPoint 2007-2013 XML AutoPlay"
:
".ms.ppsx"
,
"Microsoft Word 2007-2013 XML"
:
".ms.docx"
,
"Word 2007–365"
:
".ms.docx"
,
}.
get
(
title
,
None
)
or
{
# mediatype : extension
"application/msword"
:
".doc"
,
...
...
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