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
25c1b6cf
Commit
25c1b6cf
authored
May 25, 2011
by
Priscila Manhaes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added generic test case for cloudooo
parent
0e8a9c09
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
cloudooo/tests/cloudoooTestCase.py
cloudooo/tests/cloudoooTestCase.py
+65
-0
No files found.
cloudooo/tests/cloudoooTestCase.py
0 → 100644
View file @
25c1b6cf
import
unittest
from
xmlrpclib
import
ServerProxy
from
magic
import
Magic
class
TestCase
(
unittest
.
TestCase
):
def
getConnection
(
self
):
proxy_address
=
"http://%s:%s"
%
(
HOSTNAME
,
PORT
)
proxy
=
ServerProxy
(
proxy_address
,
allow_none
=
True
)
return
proxy
def
_getFileType
(
self
,
output_data
):
mime
=
Magic
(
mime
=
True
)
mimetype
=
mime
.
from_buffer
(
decodestring
(
output_data
))
def
_testConvertFile
(
self
,
input_url
,
source_format
,
destination_format
,
destination_mimetype
):
""" Generic test for converting file """
output_data
=
proxy
.
convertFile
(
encodestring
(
open
(
input_url
).
read
()),
source_format
,
destination_format
)
file_type
=
self
.
_getFileType
(
output_data
)
self
.
assertEquals
(
mimetype
,
destination_mimetype
)
def
_testGetMetadata
(
self
,
input_url
,
source_format
,
key
,
value
):
""" Generic tes for getting metadata file"""
metadata_dict
=
proxy
.
getFileMetadataItemList
(
encodestring
(
open
(
input_url
).
read
()),
source_format
)
self
.
assertEquals
(
metadata_dict
[
key
],
value
)
def
_testUpdateMetadata
(
self
,
input_url
,
source_format
,
metadata_dict
):
""" Generic test for setting metadata for file """
output_data
=
proxy
.
updateFileMetadata
(
encodestring
(
open
(
input_url
).
read
()),
source_format
,
metadata_dict
)
new_metadata_dict
=
proxy
.
getFileMetadataItemList
(
encodestring
(
output_data
),
source_format
)
def
getConversionScenarioList
(
self
):
"""This method must be overwrited into subclasses"""
return
[]
def
getConversionList
(
self
):
for
scenario
in
self
.
getConversionScenarioList
():
self
.
_testConvertFile
(
*
scenario
)
def
getGetMetadataScenarioList
(
self
):
"""This method must be overwrited into subclasses"""
return
[]
def
getGetMetadataList
(
self
):
for
scenario
in
self
.
getGetMetadataScenarioList
():
self
.
_testGetMetadata
(
*
scenario
)
def
getUpdateMetadataScenarioList
(
self
):
"""This method must be overwrited into subclasses"""
return
[]
def
getUpdateMetadataList
(
self
):
for
scenario
in
self
.
getUpdateMetadataScenarioList
():
self
.
_testUpdateMetadata
(
*
scenario
)
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