Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
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
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
Kirill Smelkov
cloudooo
Commits
846f6c5c
Commit
846f6c5c
authored
Sep 14, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert: test for various CSV encodings
parent
e751239c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
0 deletions
+39
-0
cloudooo/handler/ooo/tests/data/csv_ascii.csv
cloudooo/handler/ooo/tests/data/csv_ascii.csv
+1
-0
cloudooo/handler/ooo/tests/data/csv_latin9.csv
cloudooo/handler/ooo/tests/data/csv_latin9.csv
+1
-0
cloudooo/handler/ooo/tests/data/csv_utf8.csv
cloudooo/handler/ooo/tests/data/csv_utf8.csv
+2
-0
cloudooo/handler/ooo/tests/testOooServer.py
cloudooo/handler/ooo/tests/testOooServer.py
+35
-0
No files found.
cloudooo/handler/ooo/tests/data/csv_ascii.csv
0 → 100644
View file @
846f6c5c
test;1234
cloudooo/handler/ooo/tests/data/csv_latin9.csv
0 → 100644
View file @
846f6c5c
Jrome;1
cloudooo/handler/ooo/tests/data/csv_utf8.csv
0 → 100644
View file @
846f6c5c
Jérome,ジェローム
नमस्ते,여보세요
cloudooo/handler/ooo/tests/testOooServer.py
View file @
846f6c5c
##############################################################################
##############################################################################
# coding: utf-8
#
#
# Copyright (c) 2009-2010 Nexedi SA and Contributors. All Rights Reserved.
# Copyright (c) 2009-2010 Nexedi SA and Contributors. All Rights Reserved.
# Gabriel M. Monnerat <gabriel@tiolive.com>
# Gabriel M. Monnerat <gabriel@tiolive.com>
...
@@ -573,3 +574,37 @@ class TestChapterItemList(TestCase):
...
@@ -573,3 +574,37 @@ class TestChapterItemList(TestCase):
chapter
=
self
.
proxy
.
getChapterItem
(
1
,
data
,
"odt"
)
chapter
=
self
.
proxy
.
getChapterItem
(
1
,
data
,
"odt"
)
self
.
assertEquals
([
'Title 1'
,
1
],
chapter
)
self
.
assertEquals
([
'Title 1'
,
1
],
chapter
)
class
TestCSVEncoding
(
TestCase
):
"""Cloudoo tries to be "a bit" clever with CSV:
* the supported encoding is UTF-8, but also accepts latin9, for compatibility.
"""
def
test_decode_ascii
(
self
):
data
=
encodestring
(
open
(
"./data/csv_ascii.csv"
).
read
())
converted
=
decodestring
(
self
.
proxy
.
convertFile
(
data
,
"csv"
,
"html"
))
parser
=
etree
.
HTMLParser
()
tree
=
etree
.
parse
(
StringIO
(
converted
),
parser
)
self
.
assertEqual
(
[
"test"
,
"1234"
],
[
x
.
text
for
x
in
tree
.
getroot
().
find
(
'.//tr[1]'
).
iterdescendants
()
if
x
.
text
])
def
test_decode_utf8
(
self
):
data
=
encodestring
(
open
(
"./data/csv_utf8.csv"
).
read
())
converted
=
decodestring
(
self
.
proxy
.
convertFile
(
data
,
"csv"
,
"html"
))
parser
=
etree
.
HTMLParser
()
tree
=
etree
.
parse
(
StringIO
(
converted
),
parser
)
self
.
assertEqual
(
[
u"Jérome"
,
u"ジェローム"
],
[
x
.
text
for
x
in
tree
.
getroot
().
find
(
'.//tr[1]'
).
iterdescendants
()
if
x
.
text
])
self
.
assertEqual
(
[
u"नमस्ते"
,
u"여보세요"
],
[
x
.
text
for
x
in
tree
.
getroot
().
find
(
'.//tr[2]'
).
iterdescendants
()
if
x
.
text
])
def
test_decode_latin9
(
self
):
data
=
encodestring
(
open
(
"./data/csv_latin9.csv"
).
read
())
converted
=
decodestring
(
self
.
proxy
.
convertFile
(
data
,
"csv"
,
"html"
))
parser
=
etree
.
HTMLParser
()
tree
=
etree
.
parse
(
StringIO
(
converted
),
parser
)
self
.
assertEqual
(
[
u"Jérome"
,
u"1€"
],
[
x
.
text
for
x
in
tree
.
getroot
().
find
(
'.//tr[1]'
).
iterdescendants
()
if
x
.
text
])
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