Skip to content

Commit

Permalink
Revert changes which are obsolete by using the fix-doctest branch of …
Browse files Browse the repository at this point in the history
…Zope.
  • Loading branch information
Michael Howitz committed Apr 6, 2018
1 parent c9ef7e9 commit 2406480
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 112 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ python:
install:
- pip install zope.testrunner
- pip install coveralls coverage
- pip install git+https://github.com/zopefoundation/Zope.git@fix-doctest#egg=Zope
- pip install -U --pre -e .
script:
- coverage run -m zope.testrunner --path=Products --all -v
Expand Down
166 changes: 71 additions & 95 deletions Products/ExternalEditor/tests/edit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ External Editor:

>>> self.folder.manage_addFile('some-file', file='some content')

>>> print_http(r"""
>>> print http(r"""
... GET /test_folder_1_/externalEdit_/some-file.zem HTTP/1.1
... Authorization: Basic %s:%s
... """ % (user_name, user_password))
HTTP/1.1 200 OK
content-length: 167
content-type: application/x-zope-edit
date: ...
expires: ...
last-modified: ...
pragma: no-cache
x-powered-by: Zope (www.zope.org), Python (www.python.org)
Content-Length: 167
Content-Type: application/x-zope-edit
Expires:...
Last-Modified:...
Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
Expand All @@ -40,7 +38,7 @@ External Editor:
Lock the file, should now send out the lock-token in the metadata:

>>> self.folder['some-file'].wl_clearLocks()
>>> print_http(r"""
>>> print http(r"""
... LOCK /test_folder_1_/some-file HTTP/1.1
... Content-Type: text/xml; charset="utf-8"
... Depth: 0
Expand All @@ -53,20 +51,18 @@ Lock the file, should now send out the lock-token in the metadata:
... </DAV:lockinfo>""" % (user_name, user_password))
HTTP/1.1 200 OK
...
lock-token: ...
Lock-Token: ...

>>> print_http(r"""
>>> print http(r"""
... GET /test_folder_1_/externalEdit_/some-file HTTP/1.1
... Authorization: Basic %s:%s
... """ % (user_name, user_password))
HTTP/1.1 200 OK
content-length: ...
content-type: application/x-zope-edit
date: ...
expires: ...
last-modified: ...
pragma: no-cache
x-powered-by: Zope (www.zope.org), Python (www.python.org)
Content-Length: ...
Content-Type: application/x-zope-edit
Expires:...
Last-Modified:...
Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
Expand All @@ -81,18 +77,16 @@ Lock the file, should now send out the lock-token in the metadata:
If 'borrow_lock' is found in the request, then a 'borrow_lock:1' is
appended to the metadata along with the lock-token:

>>> print_http(r"""
>>> print http(r"""
... GET /test_folder_1_/externalEdit_/some-file?borrow_lock=1 HTTP/1.1
... Authorization: Basic %s:%s
... """ % (user_name, user_password))
HTTP/1.1 200 OK
content-length: ...
content-type: application/x-zope-edit
date: ...
expires: ...
last-modified: ...
pragma: no-cache
x-powered-by: Zope (www.zope.org), Python (www.python.org)
Content-Length: ...
Content-Type: application/x-zope-edit
Expires:...
Last-Modified:...
Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
Expand All @@ -108,18 +102,16 @@ appended to the metadata along with the lock-token:
If 'skip_data' is found in the request, then the file data is **not**
appended after the metadata:

>>> print_http(r"""
>>> print http(r"""
... GET /test_folder_1_/externalEdit_/some-file?skip_data=1 HTTP/1.1
... Authorization: Basic %s:%s
... """ % (user_name, user_password))
HTTP/1.1 200 OK
content-length: ...
content-type: application/x-zope-edit
date: ...
expires: ...
last-modified: ...
pragma: no-cache
x-powered-by: Zope (www.zope.org), Python (www.python.org)
Content-Length: ...
Content-Type: application/x-zope-edit
Expires:...
Last-Modified:...
Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
Expand All @@ -139,18 +131,16 @@ A user that is not the lock owner will not get the 'lock-token' or
>>> uf = self.folder.acl_users
>>> _ = uf.userFolderAddUser(user_name_2, user_password_2, ['Manager'], [])

>>> print_http(r"""
>>> print http(r"""
... GET /test_folder_1_/externalEdit_/some-file?borrow_lock=1 HTTP/1.1
... Authorization: Basic %s:%s
... """ % (user_name_2, user_password_2))
HTTP/1.1 200 OK
content-length: 163
content-type: application/x-zope-edit
date: ...
expires: ...
last-modified: ...
pragma: no-cache
x-powered-by: Zope (www.zope.org), Python (www.python.org)
Content-Length: 163
Content-Type: application/x-zope-edit
Expires:...
Last-Modified:...
Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
Expand All @@ -173,18 +163,16 @@ to 'application/x-zope-edit':
>>> from Products.ExternalEditor.tests.test_functional import SideEffects
>>> _ = self.folder._setObject('another-file', SideEffects('another-file', 'some content'))

>>> print_http(r"""
>>> print http(r"""
... GET /test_folder_1_/externalEdit_/another-file HTTP/1.1
... Authorization: Basic %s:%s
... """ % (user_name, user_password))
HTTP/1.1 200 OK
content-length: 140
content-type: application/x-zope-edit
date: ...
expires: ...
last-modified: ...
pragma: no-cache
x-powered-by: Zope (www.zope.org), Python (www.python.org)
Content-Length: 140
Content-Type: application/x-zope-edit
Expires:...
Last-Modified:...
Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/another-file
meta_type:Side Effects
Expand All @@ -207,18 +195,16 @@ that is sent out:
>>> old_cb = _callbacks[:]
>>> registerCallback(md_callback)

>>> print_http(r"""
>>> print http(r"""
... GET /test_folder_1_/externalEdit_/some-file?borrow_lock=1 HTTP/1.1
... Authorization: Basic %s:%s
... """ % (user_name, user_password))
HTTP/1.1 200 OK
content-length: 191
content-type: application/x-zope-edit
date: ...
expires: ...
last-modified: ...
pragma: no-cache
x-powered-by: Zope (www.zope.org), Python (www.python.org)
Content-Length: 191
Content-Type: application/x-zope-edit
Expires:...
Last-Modified:...
Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
Expand All @@ -241,18 +227,16 @@ REQUEST, for example the 'skip_data' parameter:
>>> old_cb = _callbacks[:]
>>> registerCallback(req_callback)

>>> print_http(r"""
>>> print http(r"""
... GET /test_folder_1_/externalEdit_/some-file HTTP/1.1
... Authorization: Basic %s:%s
... """ % (user_name, user_password))
HTTP/1.1 200 OK
content-length: 155
content-type: application/x-zope-edit
date: ...
expires: ...
last-modified: ...
pragma: no-cache
x-powered-by: Zope (www.zope.org), Python (www.python.org)
Content-Length: 155
Content-Type: application/x-zope-edit
Expires:...
Last-Modified:...
Pragma: no-cache
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
Expand All @@ -273,21 +257,17 @@ the RESPONSE:
>>> old_cb = _callbacks[:]
>>> registerCallback(resp_callback)

>>> print_http(r"""
>>> print http(r"""
... GET /test_folder_1_/externalEdit_/some-file HTTP/1.1
... Authorization: Basic %s:%s
... """ % (user_name, user_password))
HTTP/1.1 200 OK
content-encoding: gzip
content-length: 159
content-type: application/x-zope-edit
date: ...
expires: ...
last-modified: ...
pragma: no-cache
x-powered-by: Zope (www.zope.org), Python (www.python.org)
<BLANKLINE>
...
Content-Encoding: gzip
Content-Length: 159
Content-Type: application/x-zope-edit
Expires:...
Last-Modified:...
Pragma:...

>>> _callbacks[:] = old_cb

Expand All @@ -297,20 +277,18 @@ MSIE cache behaviour

We set the user agent at `MSIE` and look at the cache headers.

>>> print_http(r"""
>>> print http(r"""
... GET /test_folder_1_/externalEdit_/some-file.zem HTTP/1.1
... User-Agent: MSIE
... Authorization: Basic %s:%s
... """ % (user_name, user_password))
HTTP/1.1 200 OK
cache-control: must-revalidate, post-check=0, pre-check=0
content-length: 167
content-type: application/x-zope-edit
date: ...
expires: ...
last-modified: ...
pragma: public
x-powered-by: Zope (www.zope.org), Python (www.python.org)
Cache-Control: must-revalidate, post-check=0, pre-check=0
Content-Length: 167
Content-Type: application/x-zope-edit
Expires:...
Last-Modified:...
Pragma: public
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
Expand All @@ -324,20 +302,18 @@ We set the user agent at `MSIE` and look at the cache headers.
Because we also are IE 1.0 compliant, we try with `Microsoft Internet Explorer'
Cheers JNUT !! ;)

>>> print_http(r"""
>>> print http(r"""
... GET /test_folder_1_/externalEdit_/some-file.zem HTTP/1.1
... User-Agent: Microsoft Internet Explorer
... Authorization: Basic %s:%s
... """ % (user_name, user_password))
HTTP/1.1 200 OK
cache-control: must-revalidate, post-check=0, pre-check=0
content-length: 167
content-type: application/x-zope-edit
date: ...
expires: ...
last-modified: ...
pragma: public
x-powered-by: Zope (www.zope.org), Python (www.python.org)
Cache-Control: must-revalidate, post-check=0, pre-check=0
Content-Length: 167
Content-Type: application/x-zope-edit
Expires:...
Last-Modified:...
Pragma: public
<BLANKLINE>
url:http://localhost/test_folder_1_/some-file
meta_type:File
Expand Down
17 changes: 1 addition & 16 deletions Products/ExternalEditor/tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
##############################################################################

from __future__ import print_function
from rfc822 import Message
from StringIO import StringIO

# Load fixture
from Testing import ZopeTestCase
from OFS.SimpleItem import SimpleItem
from Testing.ZopeTestCase.zopedoctest.functional import http

# Install our product
ZopeTestCase.installProduct('ExternalEditor')
Expand All @@ -37,17 +34,6 @@ def manage_FTPget(self, REQUEST, RESPONSE):
return self.content


def print_http(request):
response = http(request)
status, _, msg = str(response).partition("\r\n")
print(status)
message = Message(StringIO(msg))
for key, value in sorted(message.items()):
print('{}: {}'.format(key, value))
print()
print(message.fp.read())


def test_suite():
import unittest
suite = unittest.TestSuite()
Expand All @@ -59,6 +45,5 @@ def test_suite():
]
for f in files:
suite.addTest(
FileSuite(f, package='Products.ExternalEditor.tests',
globs={'print_http': print_http}))
FileSuite(f, package='Products.ExternalEditor.tests'))
return suite
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ commands =
coverage run {envbindir}/zope-testrunner --path=Products --all {posargs:-vc}
deps =
.
git+https://github.com/zopefoundation/Zope.git@master#egg=Zope
git+https://github.com/zopefoundation/Zope.git@fix-doctest#egg=Zope
zope.testrunner
coverage
setenv =
Expand Down

0 comments on commit 2406480

Please sign in to comment.