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
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
Vincent Bechu
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
Show 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
unittest
import
sys
from
os
import
environ
from
ConfigParser
import
ConfigParser
from
xmlrpclib
import
ServerProxy
from
xmlrpclib
import
ServerProxy
from
magic
import
Magic
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
):
class
TestCase
(
unittest
.
TestCase
):
def
getConnection
(
self
):
def
setUp
(
self
):
proxy_address
=
"http://%s:%s"
%
(
HOSTNAME
,
PORT
)
server_cloudooo_conf
=
environ
.
get
(
"server_cloudooo_conf"
,
None
)
proxy
=
ServerProxy
(
proxy_address
,
allow_none
=
True
)
if
server_cloudooo_conf
is
not
None
:
return
proxy
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
):
def
_getFileType
(
self
,
output_data
):
mime
=
Magic
(
mime
=
True
)
mime
=
Magic
(
mime
=
True
)
mimetype
=
mime
.
from_buffer
(
decodestring
(
output_data
))
mimetype
=
mime
.
from_buffer
(
decodestring
(
output_data
))
return
mimetype
def
_testConvertFile
(
self
,
input_url
,
source_format
,
destination_format
,
def
_testConvertFile
(
self
,
input_url
,
source_format
,
destination_format
,
destination_mimetype
):
destination_mimetype
):
""" Generic test for converting file """
""" 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
,
source_format
,
destination_format
)
destination_format
)
file_type
=
self
.
_getFileType
(
output_data
)
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
):
def
_testGetMetadata
(
self
,
input_url
,
source_format
,
key
,
value
):
""" Generic tes for getting metadata file"""
""" Generic tes for getting metadata file"""
metadata_dict
=
proxy
.
getFileMetadataItemList
(
metadata_dict
=
self
.
proxy
.
getFileMetadataItemList
(
encodestring
(
open
(
input_url
).
read
()),
encodestring
(
open
(
input_url
).
read
()),
source_format
)
source_format
)
self
.
assertEquals
(
metadata_dict
[
key
],
value
)
self
.
assertEquals
(
metadata_dict
[
key
],
value
)
def
_testUpdateMetadata
(
self
,
input_url
,
source_format
,
metadata_dict
):
def
_testUpdateMetadata
(
self
,
input_url
,
source_format
,
metadata_dict
):
""" Generic test for setting metadata for file """
""" 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
,
source_format
,
metadata_dict
)
metadata_dict
)
new_metadata_dict
=
proxy
.
getFileMetadataItemList
(
new_metadata_dict
=
proxy
.
getFileMetadataItemList
(
...
@@ -43,23 +60,23 @@ class TestCase(unittest.TestCase):
...
@@ -43,23 +60,23 @@ class TestCase(unittest.TestCase):
"""This method must be overwrited into subclasses"""
"""This method must be overwrited into subclasses"""
return
[]
return
[]
def
getConversionList
(
self
):
def
runConversionList
(
self
,
scenarios
):
for
scenario
in
s
elf
.
getConversionScenarioList
()
:
for
scenario
in
s
cenarios
:
self
.
_testConvertFile
(
*
scenario
)
self
.
_testConvertFile
(
*
scenario
)
def
getGetMetadataScenarioList
(
self
):
def
getGetMetadataScenarioList
(
self
):
"""This method must be overwrited into subclasses"""
"""This method must be overwrited into subclasses"""
return
[]
return
[]
def
getGetMetadataList
(
self
):
def
runGetMetadataList
(
self
,
scenarios
):
for
scenario
in
s
elf
.
getGetMetadataScenarioList
()
:
for
scenario
in
s
cenarios
:
self
.
_testGetMetadata
(
*
scenario
)
self
.
_testGetMetadata
(
*
scenario
)
def
getUpdateMetadataScenarioList
(
self
):
def
getUpdateMetadataScenarioList
(
self
):
"""This method must be overwrited into subclasses"""
"""This method must be overwrited into subclasses"""
return
[]
return
[]
def
getUpdateMetadataList
(
self
):
def
runtUpdateMetadataList
(
self
,
scenarios
):
for
scenario
in
s
elf
.
getUpdateMetadataScenarioList
()
:
for
scenario
in
s
cenarios
:
self
.
_testUpdateMetadata
(
*
scenario
)
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