1
##############################################################################
3
# Copyright (c) 2003 Zope Corporation and Contributors.
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE.
13
##############################################################################
16
$Id: test_functional_put.py 81052 2007-10-24 19:16:25Z srichter $
19
from unittest import TestSuite, makeSuite
21
from zope.app.testing.functional import FunctionalTestCase, HTTPCaller
22
from zope.app.http.testing import AppHttpLayer
24
class TestPUT(FunctionalTestCase):
26
# PUT something for the first time
27
response = HTTPCaller()(r"""PUT /testfile.txt HTTP/1.1
28
Authorization: Basic bWdyOm1ncnB3
30
Content-Type: text/plain
32
This is just a test.""")
33
self.assertEquals(response._response.getStatus(), 201)
34
self.assertEquals(response._response.getHeader("Location"),
35
"http://localhost/testfile.txt")
37
response = HTTPCaller()(r"""GET /testfile.txt HTTP/1.1
38
Authorization: Basic bWdyOm1ncnB3""")
39
self.assertEquals(response.getBody(), "This is just a test.")
42
response = HTTPCaller()(r"""PUT /testfile.txt HTTP/1.1
43
Authorization: Basic bWdyOm1ncnB3
45
Content-Type: text/plain
47
And now it is modified.""")
48
self.assertEquals(response._response.getStatus(), 200)
49
self.assertEquals(response.getBody(), "")
51
response = HTTPCaller()(r"""GET /testfile.txt HTTP/1.1
52
Authorization: Basic bWdyOm1ncnB3""")
53
self.assertEquals(response.getBody(), "And now it is modified.")
57
TestPUT.layer = AppHttpLayer