Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Kirill Smelkov
Zope
Commits
6c2094b5
Commit
6c2094b5
authored
Mar 17, 2009
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scrub goofy module-scope imports.
parent
4ec09987
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
20 deletions
+27
-20
src/OFS/tests/testRanges.py
src/OFS/tests/testRanges.py
+27
-20
No files found.
src/OFS/tests/testRanges.py
View file @
6c2094b5
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2002-2009 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
...
...
@@ -10,19 +11,7 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import
os
,
sys
,
unittest
import
string
,
random
,
cStringIO
,
time
,
re
import
ZODB
import
transaction
from
OFS.Application
import
Application
from
OFS.Folder
import
manage_addFolder
from
OFS.Image
import
manage_addFile
from
Testing.makerequest
import
makerequest
from
webdav.common
import
rfc1123_date
from
mimetools
import
Message
from
multifile
import
MultiFile
import
unittest
def
makeConnection
():
import
ZODB
...
...
@@ -35,6 +24,9 @@ def createBigFile():
# Create a file that is several 1<<16 blocks of data big, to force the
# use of chained Pdata objects.
# Make sure we create a file that isn't of x * 1<<16 length! Coll #671
import
cStringIO
import
random
import
string
size
=
(
1
<<
16
)
*
5
+
12345
file
=
cStringIO
.
StringIO
()
...
...
@@ -51,6 +43,13 @@ BIGFILE = createBigFile()
class
TestRequestRange
(
unittest
.
TestCase
):
# Test case setup and teardown
def
setUp
(
self
):
import
cStringIO
import
string
import
transaction
from
OFS.Application
import
Application
from
OFS.Folder
import
manage_addFolder
from
OFS.Image
import
manage_addFile
from
Testing.makerequest
import
makerequest
self
.
responseOut
=
cStringIO
.
StringIO
()
self
.
connection
=
makeConnection
()
try
:
...
...
@@ -80,8 +79,11 @@ class TestRequestRange(unittest.TestCase):
raise
def
tearDown
(
self
):
try
:
self
.
app
.
_delObject
(
TESTFOLDER_NAME
)
except
AttributeError
:
pass
import
transaction
try
:
self
.
app
.
_delObject
(
TESTFOLDER_NAME
)
except
AttributeError
:
pass
transaction
.
abort
()
self
.
app
.
_p_jar
.
sync
()
self
.
connection
.
close
()
...
...
@@ -102,11 +104,12 @@ class TestRequestRange(unittest.TestCase):
# Chop off any printed headers (only when response.write was used)
if
body
:
body
=
string
.
split
(
body
,
'
\
r
\
n
\
r
\
n
'
,
1
)[
1
]
body
=
body
.
split
(
'
\
r
\
n
\
r
\
n
'
,
1
)[
1
]
return
body
+
rv
def
createLastModifiedDate
(
self
,
offset
=
0
):
from
webdav.common
import
rfc1123_date
return
rfc1123_date
(
self
.
file
.
_p_mtime
+
offset
)
def
expectUnsatisfiable
(
self
,
range
):
...
...
@@ -173,8 +176,12 @@ class TestRequestRange(unittest.TestCase):
'Incorrect range returned, expected %s, got %s'
%
(
`self.data[start:end]`
,
`body`
))
def
expectMultipleRanges
(
self
,
range
,
sets
,
draft
=
0
,
rangeParse
=
re
.
compile
(
'bytes
\
s*(
\
d+)-(
\
d+)/(
\
d+)'
)):
def
expectMultipleRanges
(
self
,
range
,
sets
,
draft
=
0
):
import
cStringIO
from
mimetools
import
Message
from
multifile
import
MultiFile
import
re
rangeParse
=
re
.
compile
(
'bytes
\
s*(
\
d+)-(
\
d+)/(
\
d+)'
)
req
=
self
.
app
.
REQUEST
rsp
=
req
.
RESPONSE
...
...
@@ -191,7 +198,7 @@ class TestRequestRange(unittest.TestCase):
self
.
failIf
(
rsp
.
getHeader
(
'content-range'
),
'The Content-Range header should not be set!'
)
ct
=
string
.
split
(
rsp
.
getHeader
(
'content-type'
),
';'
)[
0
]
ct
=
rsp
.
getHeader
(
'content-type'
).
split
(
';'
)[
0
]
draftprefix
=
draft
and
'x-'
or
''
self
.
failIf
(
ct
!=
'multipart/%sbyteranges'
%
draftprefix
,
"Incorrect Content-Type set. Expected 'multipart/%sbyteranges', "
...
...
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