Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
Thomas Leymonerie
slapos
Commits
26d8b85a
Commit
26d8b85a
authored
Aug 31, 2022
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/cloudooo/test: port the tests to python3
parent
4590d41f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
25 deletions
+24
-25
software/cloudooo/test/setup.py
software/cloudooo/test/setup.py
+0
-1
software/cloudooo/test/test.py
software/cloudooo/test/test.py
+21
-23
software/slapos-sr-testing/software-py3.cfg
software/slapos-sr-testing/software-py3.cfg
+3
-0
software/slapos-sr-testing/software.cfg
software/slapos-sr-testing/software.cfg
+0
-1
No files found.
software/cloudooo/test/setup.py
View file @
26d8b85a
...
...
@@ -45,7 +45,6 @@ setup(name=name,
'slapos.cookbook'
,
'slapos.libnetworkcache'
,
'requests'
,
'six'
,
'PyPDF2'
,
],
zip_safe
=
True
,
...
...
software/cloudooo/test/test.py
View file @
26d8b85a
##############################################################################
# coding: utf-8
#
# Copyright (c) 2020 Nexedi SA and Contributors. All Rights Reserved.
#
...
...
@@ -31,8 +30,8 @@ import csv
import
multiprocessing
import
os
import
json
import
six.moves.xmlrpc_
client
as
xmlrpclib
import
six.moves.
urllib.parse
as
urllib_parse
import
xmlrpc.
client
as
xmlrpclib
import
urllib.parse
as
urllib_parse
import
ssl
import
base64
import
io
...
...
@@ -63,6 +62,7 @@ class CloudOooTestCase(_CloudOooTestCase):
context
=
ssl_context
,
allow_none
=
True
,
)
self
.
addCleanup
(
self
.
server
(
'close'
))
def
normalizeFontName
(
font_name
):
...
...
@@ -111,16 +111,16 @@ class HTMLtoPDFConversionFontTestMixin:
def
test
(
self
):
actual_font_mapping_mapping
=
{}
for
font
in
self
.
expected_font_mapping
:
src_html
=
'''
src_html
=
f
'''
<style>
p {{ font-family: "
{
font
}
"; font-size: 20pt; }}
</style>
<p>the quick brown fox jumps over the lazy dog.</p>
<p>THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.</p>
'''
.
format
(
**
locals
())
'''
pdf_data
=
self
.
_convert_html_to_pdf
(
src_html
)
pdf_reader
=
PyPDF2
.
PdfFileReader
(
io
.
BytesIO
(
(
pdf_data
)
))
pdf_reader
=
PyPDF2
.
PdfFileReader
(
io
.
BytesIO
(
pdf_data
))
self
.
assertEqual
(
self
.
pdf_producer
,
pdf_reader
.
getDocumentInfo
()[
'/Producer'
])
...
...
@@ -165,7 +165,7 @@ class TestWkhtmlToPDF(HTMLtoPDFConversionFontTestMixin, CloudOooTestCase):
'Liberation Sans Narrow'
:
'LiberationSansNarrow'
,
'Liberation Serif'
:
'LiberationSerif'
,
'Linux LibertineG'
:
'LiberationSans'
,
'OpenSymbol'
:
set
([
'DejaVuSans'
,
'OpenSymbol'
])
,
'OpenSymbol'
:
{
'DejaVuSans'
,
'OpenSymbol'
}
,
'Palatino'
:
'LiberationSans'
,
'Roboto Black'
:
'LiberationSans'
,
'Roboto Condensed Light'
:
'LiberationSans'
,
...
...
@@ -180,9 +180,9 @@ class TestWkhtmlToPDF(HTMLtoPDFConversionFontTestMixin, CloudOooTestCase):
}
def
_convert_html_to_pdf
(
self
,
src_html
):
return
base64
.
decode
string
(
return
base64
.
decode
bytes
(
self
.
server
.
convertFile
(
base64
.
encode
string
(
src_html
.
encode
()).
decode
(),
base64
.
encode
bytes
(
src_html
.
encode
()).
decode
(),
'html'
,
'pdf'
,
False
,
...
...
@@ -238,9 +238,9 @@ class TestLibreoffice(HTMLtoPDFConversionFontTestMixin, CloudOooTestCase):
}
def
_convert_html_to_pdf
(
self
,
src_html
):
return
base64
.
decode
string
(
return
base64
.
decode
bytes
(
self
.
server
.
convertFile
(
base64
.
encode
string
(
src_html
.
encode
()).
decode
(),
base64
.
encode
bytes
(
src_html
.
encode
()).
decode
(),
'html'
,
'pdf'
,
).
encode
())
...
...
@@ -251,10 +251,10 @@ class TestLibreOfficeTextConversion(CloudOooTestCase):
def
test_html_to_text
(
self
):
self
.
assertEqual
(
base64
.
decode
string
(
base64
.
decode
bytes
(
self
.
server
.
convertFile
(
base64
.
encode
string
(
u'<html>héhé</html>'
.
encode
(
'utf-8'
)).
decode
(),
base64
.
encode
bytes
(
'<html>héhé</html>'
.
encode
(
)).
decode
(),
'html'
,
'txt'
,
).
encode
()),
...
...
@@ -274,19 +274,18 @@ class TestLibreOfficeCluster(CloudOooTestCase):
global
_convert_html_to_text
def
_convert_html_to_text
(
src_html
):
return
base64
.
decode
string
(
return
base64
.
decode
bytes
(
self
.
server
.
convertFile
(
base64
.
encode
string
(
src_html
.
encode
()).
decode
(),
base64
.
encode
bytes
(
src_html
.
encode
()).
decode
(),
'html'
,
'txt'
,
).
encode
())
pool
=
multiprocessing
.
Pool
(
5
)
# TODO py3: use with pool
converted
=
pool
.
map
(
_convert_html_to_text
,
[
'<html><body>hello</body></html>'
]
*
100
)
pool
.
terminate
()
pool
.
join
()
with
pool
:
converted
=
pool
.
map
(
_convert_html_to_text
,
[
'<html><body>hello</body></html>'
]
*
100
)
self
.
assertEqual
(
converted
,
[
codecs
.
BOM_UTF8
+
b'hello
\
n
'
]
*
100
)
...
...
@@ -294,9 +293,8 @@ class TestLibreOfficeCluster(CloudOooTestCase):
res
=
requests
.
get
(
urllib_parse
.
urljoin
(
self
.
url
,
'/haproxy;csv'
),
verify
=
False
,
stream
=
True
,
)
reader
=
csv
.
DictReader
(
res
.
raw
)
reader
=
csv
.
DictReader
(
io
.
StringIO
(
res
.
text
)
)
line_list
=
list
(
reader
)
# requests have been balanced
total_hrsp_2xx
=
{
...
...
software/slapos-sr-testing/software-py3.cfg
View file @
26d8b85a
...
...
@@ -42,3 +42,6 @@ extra =
seleniumserver ${slapos.test.seleniumserver-setup:setup}
theia ${slapos.test.theia-setup:setup}
turnserver ${slapos.test.turnserver-setup:setup}
### WIP: python2 softwares tested with python3
cloudooo ${slapos.test.cloudooo-setup:setup}
software/slapos-sr-testing/software.cfg
View file @
26d8b85a
...
...
@@ -367,7 +367,6 @@ extra =
# You should not add more lines here.
backupserver ${slapos.test.backupserver-setup:setup}
beremiz-ide ${slapos.test.beremiz-ide-setup:setup}
cloudooo ${slapos.test.cloudooo-setup:setup}
dream ${slapos.test.dream-setup:setup}
gitlab ${slapos.test.gitlab-setup:setup}
re6stnet ${slapos.test.re6stnet-setup:setup}
...
...
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