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
a1fce5b9
Commit
a1fce5b9
authored
May 31, 2011
by
Priscila Manhaes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor for using cloudoootestcase
parent
ad8a6afb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
31 deletions
+22
-31
cloudooo/handler/pdf/tests/testServer.py
cloudooo/handler/pdf/tests/testServer.py
+22
-31
No files found.
cloudooo/handler/pdf/tests/testServer.py
View file @
a1fce5b9
...
@@ -26,51 +26,42 @@
...
@@ -26,51 +26,42 @@
#
#
##############################################################################
##############################################################################
from
cloudooo.tests.handlerTestCase
import
HandlerTestCase
,
make_suite
from
xmlrpclib
import
ServerProxy
from
os.path
import
join
from
os.path
import
join
from
base64
import
encodestring
,
decodestring
from
cloudooo.tests.cloudoooTestCase
import
TestCase
,
make_suite
from
magic
import
Magic
DAEMON
=
True
class
TestServer
(
TestCase
):
class
TestServer
(
HandlerTestCase
):
"""Test XmlRpc Server. Needs cloudooo server started"""
"""Test XmlRpc Server. Needs cloudooo server started"""
def
afterSetUp
(
self
):
def
ConversionScenarioList
(
self
):
"""Creates a connection with cloudooo server"""
return
[
self
.
proxy
=
ServerProxy
(
"http://%s:%s/RPC2"
%
\
(
join
(
'data'
,
'test.pdf'
),
"pdf"
,
"txt"
,
"text/plain"
),
(
self
.
hostname
,
self
.
cloudooo_port
),
allow_none
=
True
)
]
def
testConvertPDFtoTxt
(
self
):
def
testConvertPDFtoTxt
(
self
):
"""Converts pdf to txt"""
"""Converts pdf to txt"""
data
=
open
(
join
(
'data'
,
'test.pdf'
),
'r'
).
read
(
)
self
.
runConversionList
(
self
.
ConversionScenarioList
()
)
document
=
self
.
proxy
.
convertFile
(
encodestring
(
data
),
"pdf"
,
def
GetMetadataScenarioList
(
self
):
"txt"
)
return
[
mime
=
Magic
(
mime
=
True
)
(
join
(
'data'
,
'test.pdf'
),
"pdf"
,
dict
(
title
=
'Free Cloud Alliance'
+
mimetype
=
mime
.
from_buffer
(
decodestring
(
document
))
' Presentation'
)),
self
.
assertEquals
(
mimetype
,
"text/plain"
)
]
def
testGetMetadataFromPdf
(
self
):
def
testGetMetadataFromPdf
(
self
):
"""test if metadata are extracted correctly"""
"""test if metadata are extracted correctly"""
data
=
open
(
join
(
'data'
,
'test.pdf'
),
'r'
).
read
()
self
.
runGetMetadataList
(
self
.
GetMetadataScenarioList
())
metadata
=
self
.
proxy
.
getFileMetadataItemList
(
encodestring
(
data
),
"pdf"
)
self
.
assertEquals
(
metadata
[
"title"
],
def
UpdateMetadataScenarioList
(
self
):
'Free Cloud Alliance Presentation'
)
return
[
(
join
(
'data'
,
'test.pdf'
),
"pdf"
,
dict
(
producer
=
'Cloudooo'
),
dict
(
title
=
'Free Cloud Alliance Presentation'
,
producer
=
'Cloudooo'
)
),
]
def
testSetMetadata
(
self
):
def
testSetMetadata
(
self
):
"""Test if metadata is inserted correctly in document"""
"""Test if metadata is inserted correctly in document"""
data
=
open
(
join
(
'data'
,
'test.pdf'
),
'r'
).
read
()
self
.
runUpdateMetadataList
(
self
.
UpdateMetadataScenarioList
())
new_data
=
self
.
proxy
.
updateFileMetadata
(
encodestring
(
data
),
"pdf"
,
{
"producer"
:
"Cloudooo"
})
metadata
=
self
.
proxy
.
getFileMetadataItemList
(
new_data
,
"pdf"
)
self
.
assertEquals
(
metadata
[
"title"
],
'Free Cloud Alliance Presentation'
)
self
.
assertEquals
(
metadata
[
"producer"
],
'Cloudooo'
)
def
test_suite
():
def
test_suite
():
return
make_suite
(
TestServer
)
return
make_suite
(
TestServer
)
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