Commit 9499e514 authored by Łukasz Nowak's avatar Łukasz Nowak

Fix test.

Follow new way of POSTing instead of putting.
parent 46e1fa2e
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
import base64 import base64
import os
import transaction import transaction
import httplib import httplib
from DateTime import DateTime from DateTime import DateTime
...@@ -77,7 +76,7 @@ class TestShaCacheExternal(ShaCacheMixin, ShaSecurityMixin, ERP5TypeTestCase): ...@@ -77,7 +76,7 @@ class TestShaCacheExternal(ShaCacheMixin, ShaSecurityMixin, ERP5TypeTestCase):
# HTTP Connection properties # HTTP Connection properties
self.host = self.portal.REQUEST.get('SERVER_NAME') self.host = self.portal.REQUEST.get('SERVER_NAME')
self.port = self.portal.REQUEST.get('SERVER_PORT') self.port = self.portal.REQUEST.get('SERVER_PORT')
self.path = os.path.join(self.shacache.getPath(), self.key) self.path = self.shacache.getPath()
def test_external_post(self): def test_external_post(self):
""" """
...@@ -86,15 +85,15 @@ class TestShaCacheExternal(ShaCacheMixin, ShaSecurityMixin, ERP5TypeTestCase): ...@@ -86,15 +85,15 @@ class TestShaCacheExternal(ShaCacheMixin, ShaSecurityMixin, ERP5TypeTestCase):
now = DateTime() now = DateTime()
connection = httplib.HTTPConnection('%s:%s' % (self.host, self.port)) connection = httplib.HTTPConnection('%s:%s' % (self.host, self.port))
try: try:
connection.request('PUT', self.path, self.data, self.header_dict) connection.request('POST', self.path, self.data, self.header_dict)
result = connection.getresponse() result = connection.getresponse()
transaction.commit() transaction.commit()
self.tic() self.tic()
data = result.read() data = result.read()
finally: finally:
connection.close() connection.close()
self.assertEquals('', data) self.assertEquals(self.key, data)
self.assertEquals(201, result.status) self.assertEquals(httplib.CREATED, result.status)
# Check Document # Check Document
document = self.portal.portal_catalog.getResultValue(portal_type='File', document = self.portal.portal_catalog.getResultValue(portal_type='File',
...@@ -117,13 +116,14 @@ class TestShaCacheExternal(ShaCacheMixin, ShaSecurityMixin, ERP5TypeTestCase): ...@@ -117,13 +116,14 @@ class TestShaCacheExternal(ShaCacheMixin, ShaSecurityMixin, ERP5TypeTestCase):
connection = httplib.HTTPConnection('%s:%s' % (self.host, self.port)) connection = httplib.HTTPConnection('%s:%s' % (self.host, self.port))
try: try:
connection.request('GET', self.path, headers=header_dict) connection.request('GET', '/'.join([self.path, self.key]),
headers=header_dict)
result = connection.getresponse() result = connection.getresponse()
data = result.read() data = result.read()
finally: finally:
connection.close() connection.close()
self.assertEquals(self.data, data) self.assertEquals(self.data, data)
self.assertEquals(200, result.status) self.assertEquals(httplib.OK, result.status)
self.assertEquals(self.expected_content_type, self.assertEquals(self.expected_content_type,
result.getheader("content-type")) result.getheader("content-type"))
...@@ -141,7 +141,7 @@ class TestShaCacheExternal(ShaCacheMixin, ShaSecurityMixin, ERP5TypeTestCase): ...@@ -141,7 +141,7 @@ class TestShaCacheExternal(ShaCacheMixin, ShaSecurityMixin, ERP5TypeTestCase):
connection = httplib.HTTPConnection('%s:%s' % (self.host, self.port)) connection = httplib.HTTPConnection('%s:%s' % (self.host, self.port))
header_dict = {'Content-Type': self.content_type} header_dict = {'Content-Type': self.content_type}
try: try:
connection.request('PUT', self.path, self.data, header_dict) connection.request('POST', self.path, self.data, header_dict)
result = connection.getresponse() result = connection.getresponse()
transaction.commit() transaction.commit()
self.tic() self.tic()
......
22 23
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment