Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
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 @@
#
##############################################################################
from
cloudooo.tests.handlerTestCase
import
HandlerTestCase
,
make_suite
from
xmlrpclib
import
ServerProxy
from
os.path
import
join
from
base64
import
encodestring
,
decodestring
from
magic
import
Magic
from
cloudooo.tests.cloudoooTestCase
import
TestCase
,
make_suite
DAEMON
=
True
class
TestServer
(
HandlerTestCase
):
class
TestServer
(
TestCase
):
"""Test XmlRpc Server. Needs cloudooo server started"""
def
afterSetUp
(
self
):
"""Creates a connection with cloudooo server"""
self
.
proxy
=
ServerProxy
(
"http://%s:%s/RPC2"
%
\
(
self
.
hostname
,
self
.
cloudooo_port
),
allow_none
=
True
)
def
ConversionScenarioList
(
self
):
return
[
(
join
(
'data'
,
'test.pdf'
),
"pdf"
,
"txt"
,
"text/plain"
),
]
def
testConvertPDFtoTxt
(
self
):
"""Converts pdf to txt"""
data
=
open
(
join
(
'data'
,
'test.pdf'
),
'r'
).
read
(
)
document
=
self
.
proxy
.
convertFile
(
encodestring
(
data
),
"pdf"
,
"txt"
)
mime
=
Magic
(
mime
=
True
)
mimetype
=
mime
.
from_buffer
(
decodestring
(
document
))
self
.
assertEquals
(
mimetype
,
"text/plain"
)
self
.
runConversionList
(
self
.
ConversionScenarioList
()
)
def
GetMetadataScenarioList
(
self
):
return
[
(
join
(
'data'
,
'test.pdf'
),
"pdf"
,
dict
(
title
=
'Free Cloud Alliance'
+
' Presentation'
)),
]
def
testGetMetadataFromPdf
(
self
):
"""test if metadata are extracted correctly"""
data
=
open
(
join
(
'data'
,
'test.pdf'
),
'r'
).
read
()
metadata
=
self
.
proxy
.
getFileMetadataItemList
(
encodestring
(
data
),
"pdf"
)
self
.
assertEquals
(
metadata
[
"title"
],
'Free Cloud Alliance Presentation'
)
self
.
runGetMetadataList
(
self
.
GetMetadataScenarioList
())
def
UpdateMetadataScenarioList
(
self
):
return
[
(
join
(
'data'
,
'test.pdf'
),
"pdf"
,
dict
(
producer
=
'Cloudooo'
),
dict
(
title
=
'Free Cloud Alliance Presentation'
,
producer
=
'Cloudooo'
)
),
]
def
testSetMetadata
(
self
):
"""Test if metadata is inserted correctly in document"""
data
=
open
(
join
(
'data'
,
'test.pdf'
),
'r'
).
read
()
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'
)
self
.
runUpdateMetadataList
(
self
.
UpdateMetadataScenarioList
())
def
test_suite
():
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