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
a92728b3
Commit
a92728b3
authored
May 30, 2011
by
Priscila Manhaes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified for verifing connetion, added make_suite for running all tests into file
parent
d36c8223
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
14 deletions
+31
-14
cloudooo/tests/cloudoooTestCase.py
cloudooo/tests/cloudoooTestCase.py
+31
-14
No files found.
cloudooo/tests/cloudoooTestCase.py
View file @
a92728b3
import
unittest
import
sys
from
os
import
environ
from
ConfigParser
import
ConfigParser
from
xmlrpclib
import
ServerProxy
from
magic
import
Magic
from
base64
import
encodestring
,
decodestring
config
=
ConfigParser
()
def
make_suite
(
test_case
):
"""Function is used to run all tests together"""
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
test_case
))
return
suite
class
TestCase
(
unittest
.
TestCase
):
def
getConnection
(
self
):
proxy_address
=
"http://%s:%s"
%
(
HOSTNAME
,
PORT
)
proxy
=
ServerProxy
(
proxy_address
,
allow_none
=
True
)
return
proxy
def
setUp
(
self
):
server_cloudooo_conf
=
environ
.
get
(
"server_cloudooo_conf"
,
None
)
if
server_cloudooo_conf
is
not
None
:
config
.
read
(
server_cloudooo_conf
)
self
.
hostname
=
config
.
get
(
"server:main"
,
"host"
)
self
.
port
=
config
.
get
(
"server:main"
,
"port"
)
self
.
proxy
=
ServerProxy
((
"http://%s:%s/RPC2"
%
(
self
.
hostname
,
self
.
port
)),
\
allow_none
=
True
)
def
_getFileType
(
self
,
output_data
):
mime
=
Magic
(
mime
=
True
)
mimetype
=
mime
.
from_buffer
(
decodestring
(
output_data
))
return
mimetype
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
()),
output_data
=
self
.
proxy
.
convertFile
(
encodestring
(
open
(
input_url
).
read
()),
source_format
,
destination_format
)
file_type
=
self
.
_getFileType
(
output_data
)
self
.
assertEquals
(
mime
type
,
destination_mimetype
)
self
.
assertEquals
(
file_
type
,
destination_mimetype
)
def
_testGetMetadata
(
self
,
input_url
,
source_format
,
key
,
value
):
""" Generic tes for getting metadata file"""
metadata_dict
=
proxy
.
getFileMetadataItemList
(
metadata_dict
=
self
.
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
()),
output_data
=
self
.
proxy
.
updateFileMetadata
(
encodestring
(
open
(
input_url
).
read
()),
source_format
,
metadata_dict
)
new_metadata_dict
=
proxy
.
getFileMetadataItemList
(
...
...
@@ -43,23 +60,23 @@ class TestCase(unittest.TestCase):
"""This method must be overwrited into subclasses"""
return
[]
def
getConversionList
(
self
):
for
scenario
in
s
elf
.
getConversionScenarioList
()
:
def
runConversionList
(
self
,
scenarios
):
for
scenario
in
s
cenarios
:
self
.
_testConvertFile
(
*
scenario
)
def
getGetMetadataScenarioList
(
self
):
"""This method must be overwrited into subclasses"""
return
[]
def
getGetMetadataList
(
self
):
for
scenario
in
s
elf
.
getGetMetadataScenarioList
()
:
def
runGetMetadataList
(
self
,
scenarios
):
for
scenario
in
s
cenarios
:
self
.
_testGetMetadata
(
*
scenario
)
def
getUpdateMetadataScenarioList
(
self
):
"""This method must be overwrited into subclasses"""
return
[]
def
getUpdateMetadataList
(
self
):
for
scenario
in
s
elf
.
getUpdateMetadataScenarioList
()
:
def
runtUpdateMetadataList
(
self
,
scenarios
):
for
scenario
in
s
cenarios
:
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