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
fa7ed25b
Commit
fa7ed25b
authored
Apr 22, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: use assertIsInstance
This does not need the types module which no longer exist
parent
2c7959c0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
16 deletions
+12
-16
cloudooo/handler/ooo/tests/testOooMonitorMemory.py
cloudooo/handler/ooo/tests/testOooMonitorMemory.py
+2
-3
cloudooo/handler/ooo/tests/testOooOdfDocument.py
cloudooo/handler/ooo/tests/testOooOdfDocument.py
+2
-2
cloudooo/handler/ooo/tests/testOooServer.py
cloudooo/handler/ooo/tests/testOooServer.py
+6
-7
cloudooo/handler/pdf/tests/testPdfHandler.py
cloudooo/handler/pdf/tests/testPdfHandler.py
+1
-2
cloudooo/tests/cloudoooTestCase.py
cloudooo/tests/cloudoooTestCase.py
+1
-2
No files found.
cloudooo/handler/ooo/tests/testOooMonitorMemory.py
View file @
fa7ed25b
...
@@ -33,7 +33,6 @@ from time import sleep
...
@@ -33,7 +33,6 @@ from time import sleep
from
cloudooo.handler.ooo.application.openoffice
import
openoffice
from
cloudooo.handler.ooo.application.openoffice
import
openoffice
from
cloudooo.handler.ooo.monitor.memory
import
MonitorMemory
from
cloudooo.handler.ooo.monitor.memory
import
MonitorMemory
from
psutil
import
Process
from
psutil
import
Process
from
types
import
IntType
OPENOFFICE
=
True
OPENOFFICE
=
True
...
@@ -94,7 +93,7 @@ class TestMonitorMemory(unittest.TestCase):
...
@@ -94,7 +93,7 @@ class TestMonitorMemory(unittest.TestCase):
self
.
monitor
=
MonitorMemory
(
openoffice
,
2
,
400
)
self
.
monitor
=
MonitorMemory
(
openoffice
,
2
,
400
)
self
.
monitor
.
create_process
()
self
.
monitor
.
create_process
()
self
.
assertTrue
(
hasattr
(
self
.
monitor
,
'process'
))
self
.
assertTrue
(
hasattr
(
self
.
monitor
,
'process'
))
self
.
assert
Equal
(
type
(
self
.
monitor
.
process
)
,
Process
)
self
.
assert
IsInstance
(
self
.
monitor
.
process
,
Process
)
def
testGetMemoryUsage
(
self
):
def
testGetMemoryUsage
(
self
):
"""Test memory usage"""
"""Test memory usage"""
...
@@ -105,6 +104,6 @@ class TestMonitorMemory(unittest.TestCase):
...
@@ -105,6 +104,6 @@ class TestMonitorMemory(unittest.TestCase):
if
not
openoffice
.
status
():
if
not
openoffice
.
status
():
openoffice
.
start
()
openoffice
.
start
()
memory_usage_int
=
self
.
monitor
.
get_memory_usage
()
memory_usage_int
=
self
.
monitor
.
get_memory_usage
()
self
.
assert
Equal
(
type
(
memory_usage_int
),
IntType
)
self
.
assert
IsInstance
(
memory_usage_int
,
int
)
cloudooo/handler/ooo/tests/testOooOdfDocument.py
View file @
fa7ed25b
...
@@ -43,7 +43,7 @@ class TestOdfDocument(HandlerTestCase):
...
@@ -43,7 +43,7 @@ class TestOdfDocument(HandlerTestCase):
def
testReceivedGoodFile
(
self
):
def
testReceivedGoodFile
(
self
):
"""Test if received path is from a good document returing an ZipFile"""
"""Test if received path is from a good document returing an ZipFile"""
self
.
assert
True
(
isinstance
(
self
.
oodocument
.
_zipfile
,
ZipFile
)
)
self
.
assert
IsInstance
(
self
.
oodocument
.
_zipfile
,
ZipFile
)
def
testGetContentXml
(
self
):
def
testGetContentXml
(
self
):
"""Test if the getContentXml method returns the content.xml file"""
"""Test if the getContentXml method returns the content.xml file"""
...
@@ -63,7 +63,7 @@ class TestOdfDocument(HandlerTestCase):
...
@@ -63,7 +63,7 @@ class TestOdfDocument(HandlerTestCase):
def
testParseContent
(
self
):
def
testParseContent
(
self
):
"""Test if the _parsed_content attribute is the parsed content.xml"""
"""Test if the _parsed_content attribute is the parsed content.xml"""
# XXX not sure it is good to store parsed document everytime
# XXX not sure it is good to store parsed document everytime
self
.
assert
True
(
isinstance
(
self
.
oodocument
.
parsed_content
,
etree
.
_Element
)
)
self
.
assert
IsInstance
(
self
.
oodocument
.
parsed_content
,
etree
.
_Element
)
self
.
assertTrue
(
self
.
oodocument
.
parsed_content
.
tag
.
endswith
(
self
.
assertTrue
(
self
.
oodocument
.
parsed_content
.
tag
.
endswith
(
'document-content'
))
'document-content'
))
...
...
cloudooo/handler/ooo/tests/testOooServer.py
View file @
fa7ed25b
...
@@ -34,7 +34,6 @@ from os import remove
...
@@ -34,7 +34,6 @@ from os import remove
from
base64
import
encodestring
,
decodestring
from
base64
import
encodestring
,
decodestring
from
StringIO
import
StringIO
from
StringIO
import
StringIO
from
lxml
import
etree
from
lxml
import
etree
from
types
import
DictType
from
zipfile
import
ZipFile
,
is_zipfile
from
zipfile
import
ZipFile
,
is_zipfile
from
cloudooo.tests.cloudoooTestCase
import
TestCase
from
cloudooo.tests.cloudoooTestCase
import
TestCase
from
cloudooo.tests.backportUnittest
import
expectedFailure
from
cloudooo.tests.backportUnittest
import
expectedFailure
...
@@ -226,7 +225,7 @@ class TestGetMetadata(TestCase):
...
@@ -226,7 +225,7 @@ class TestGetMetadata(TestCase):
'application/vnd.oasis.opendocument.text'
)
'application/vnd.oasis.opendocument.text'
)
response_code
,
response_dict
,
response_message
=
generate_result
response_code
,
response_dict
,
response_message
=
generate_result
self
.
assertEqual
(
response_code
,
200
)
self
.
assertEqual
(
response_code
,
200
)
self
.
assert
Equal
(
type
(
response_dict
),
DictType
)
self
.
assert
IsInstance
(
response_dict
,
dict
)
self
.
assertNotEqual
(
response_dict
[
'data'
],
''
)
self
.
assertNotEqual
(
response_dict
[
'data'
],
''
)
self
.
assertEqual
(
response_dict
[
'mime'
],
'application/pdf'
)
self
.
assertEqual
(
response_dict
[
'mime'
],
'application/pdf'
)
...
@@ -245,7 +244,7 @@ class TestGenerate(TestCase):
...
@@ -245,7 +244,7 @@ class TestGenerate(TestCase):
"application/vnd.oasis.opendocument.spreadsheet"
)
"application/vnd.oasis.opendocument.spreadsheet"
)
response_code
,
response_dict
,
response_message
=
generate_result
response_code
,
response_dict
,
response_message
=
generate_result
self
.
assertEqual
(
response_code
,
200
)
self
.
assertEqual
(
response_code
,
200
)
self
.
assert
Equal
(
type
(
response_dict
),
DictType
)
self
.
assert
IsInstance
(
response_dict
,
dict
)
self
.
assertNotEqual
(
response_dict
[
'data'
],
''
)
self
.
assertNotEqual
(
response_dict
[
'data'
],
''
)
self
.
assertEqual
(
response_dict
[
'mime'
],
'application/zip'
)
self
.
assertEqual
(
response_dict
[
'mime'
],
'application/zip'
)
output_url
=
join
(
self
.
tmp_url
,
"zip.zip"
)
output_url
=
join
(
self
.
tmp_url
,
"zip.zip"
)
...
@@ -272,7 +271,7 @@ class TestGenerate(TestCase):
...
@@ -272,7 +271,7 @@ class TestGenerate(TestCase):
"application/vnd.oasis.opendocument.spreadsheet"
)
"application/vnd.oasis.opendocument.spreadsheet"
)
response_code
,
response_dict
,
response_message
=
generate_result
response_code
,
response_dict
,
response_message
=
generate_result
self
.
assertEqual
(
response_code
,
200
)
self
.
assertEqual
(
response_code
,
200
)
self
.
assert
Equal
(
type
(
response_dict
),
DictType
)
self
.
assert
IsInstance
(
response_dict
,
dict
)
self
.
assertNotEqual
(
response_dict
[
'data'
],
''
)
self
.
assertNotEqual
(
response_dict
[
'data'
],
''
)
self
.
assertEqual
(
response_dict
[
'mime'
],
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
)
self
.
assertEqual
(
response_dict
[
'mime'
],
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
)
...
@@ -289,7 +288,7 @@ class TestGenerate(TestCase):
...
@@ -289,7 +288,7 @@ class TestGenerate(TestCase):
'application/vnd.oasis.opendocument.presentation'
)
'application/vnd.oasis.opendocument.presentation'
)
response_code
,
response_dict
,
response_message
=
generate_result
response_code
,
response_dict
,
response_message
=
generate_result
self
.
assertEqual
(
response_code
,
200
)
self
.
assertEqual
(
response_code
,
200
)
self
.
assert
Equal
(
type
(
response_dict
),
DictType
)
self
.
assert
IsInstance
(
response_dict
,
dict
)
self
.
assertNotEqual
(
response_dict
[
'data'
],
''
)
self
.
assertNotEqual
(
response_dict
[
'data'
],
''
)
self
.
assertEqual
(
response_dict
[
'mime'
],
'application/zip'
)
self
.
assertEqual
(
response_dict
[
'mime'
],
'application/zip'
)
output_url
=
join
(
self
.
tmp_url
,
"zip.zip"
)
output_url
=
join
(
self
.
tmp_url
,
"zip.zip"
)
...
@@ -323,7 +322,7 @@ class TestGenerate(TestCase):
...
@@ -323,7 +322,7 @@ class TestGenerate(TestCase):
'application/vnd.oasis.opendocument.presentation'
)
'application/vnd.oasis.opendocument.presentation'
)
response_code
,
response_dict
,
response_message
=
generate_result
response_code
,
response_dict
,
response_message
=
generate_result
self
.
assertEqual
(
response_code
,
200
)
self
.
assertEqual
(
response_code
,
200
)
self
.
assert
Equal
(
type
(
response_dict
),
DictType
)
self
.
assert
IsInstance
(
response_dict
,
dict
)
self
.
assertNotEqual
(
response_dict
[
'data'
],
''
)
self
.
assertNotEqual
(
response_dict
[
'data'
],
''
)
self
.
assertEqual
(
response_dict
[
'mime'
],
'application/zip'
)
self
.
assertEqual
(
response_dict
[
'mime'
],
'application/zip'
)
output_url
=
join
(
self
.
tmp_url
,
"zip.zip"
)
output_url
=
join
(
self
.
tmp_url
,
"zip.zip"
)
...
@@ -351,7 +350,7 @@ class TestGenerate(TestCase):
...
@@ -351,7 +350,7 @@ class TestGenerate(TestCase):
None
,
'pdf'
,
'application/vnd.oasis.opendocument.text'
)
None
,
'pdf'
,
'application/vnd.oasis.opendocument.text'
)
response_code
,
response_dict
,
response_message
=
generate_result
response_code
,
response_dict
,
response_message
=
generate_result
self
.
assertEqual
(
response_code
,
402
)
self
.
assertEqual
(
response_code
,
402
)
self
.
assert
Equal
(
type
(
response_dict
),
DictType
)
self
.
assert
IsInstance
(
response_dict
,
dict
)
self
.
assertEqual
(
response_dict
,
{})
self
.
assertEqual
(
response_dict
,
{})
self
.
assertTrue
(
response_message
.
startswith
(
'Traceback'
))
self
.
assertTrue
(
response_message
.
startswith
(
'Traceback'
))
...
...
cloudooo/handler/pdf/tests/testPdfHandler.py
View file @
fa7ed25b
...
@@ -31,7 +31,6 @@
...
@@ -31,7 +31,6 @@
from
cloudooo.handler.pdf.handler
import
Handler
from
cloudooo.handler.pdf.handler
import
Handler
from
cloudooo.tests.handlerTestCase
import
HandlerTestCase
from
cloudooo.tests.handlerTestCase
import
HandlerTestCase
from
types
import
DictType
class
TestHandler
(
HandlerTestCase
):
class
TestHandler
(
HandlerTestCase
):
...
@@ -53,7 +52,7 @@ class TestHandler(HandlerTestCase):
...
@@ -53,7 +52,7 @@ class TestHandler(HandlerTestCase):
pdf_document
=
f
.
read
()
pdf_document
=
f
.
read
()
handler
=
Handler
(
self
.
tmp_url
,
pdf_document
,
"pdf"
,
**
self
.
kw
)
handler
=
Handler
(
self
.
tmp_url
,
pdf_document
,
"pdf"
,
**
self
.
kw
)
metadata
=
handler
.
getMetadata
()
metadata
=
handler
.
getMetadata
()
self
.
assert
Equal
(
type
(
metadata
),
DictType
)
self
.
assert
IsInstance
(
metadata
,
dict
)
self
.
assertNotEqual
(
metadata
,
{})
self
.
assertNotEqual
(
metadata
,
{})
self
.
assertEqual
(
metadata
[
"title"
],
'Free Cloud Alliance Presentation'
)
self
.
assertEqual
(
metadata
[
"title"
],
'Free Cloud Alliance Presentation'
)
...
...
cloudooo/tests/cloudoooTestCase.py
View file @
fa7ed25b
...
@@ -33,7 +33,6 @@ from os import environ, path
...
@@ -33,7 +33,6 @@ from os import environ, path
from
ConfigParser
import
ConfigParser
from
ConfigParser
import
ConfigParser
from
xmlrpclib
import
ServerProxy
,
Fault
from
xmlrpclib
import
ServerProxy
,
Fault
from
magic
import
Magic
from
magic
import
Magic
from
types
import
DictType
from
base64
import
encodestring
,
decodestring
from
base64
import
encodestring
,
decodestring
from
cloudooo.tests
import
backportUnittest
from
cloudooo.tests
import
backportUnittest
...
@@ -132,7 +131,7 @@ class TestCase(backportUnittest.TestCase):
...
@@ -132,7 +131,7 @@ class TestCase(backportUnittest.TestCase):
response_code
,
response_dict
,
response_message
=
\
response_code
,
response_dict
,
response_message
=
\
self
.
proxy
.
run_convert
(
filename
,
encodestring
(
data
))
self
.
proxy
.
run_convert
(
filename
,
encodestring
(
data
))
self
.
assertEqual
(
response_code
,
expected_response_code
)
self
.
assertEqual
(
response_code
,
expected_response_code
)
self
.
assert
Equal
(
type
(
response_dict
),
DictType
)
self
.
assert
IsInstance
(
response_dict
,
dict
)
if
expected_response_code
==
402
:
if
expected_response_code
==
402
:
self
.
assertEqual
(
response_dict
,
{})
self
.
assertEqual
(
response_dict
,
{})
self
.
assertTrue
(
response_message
.
endswith
(
expected_response_message
),
self
.
assertTrue
(
response_message
.
endswith
(
expected_response_message
),
...
...
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