Commit ad38c89d authored by Lucas Carvalho's avatar Lucas Carvalho

Updated test with latest changes.

parent f0ff55f1
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
import transaction import transaction
import httplib
from StringIO import StringIO from StringIO import StringIO
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from ShaCacheMixin import ShaCacheMixin from ShaCacheMixin import ShaCacheMixin
...@@ -55,7 +56,7 @@ class TestShaCache(ShaCacheMixin, ERP5TypeTestCase): ...@@ -55,7 +56,7 @@ class TestShaCache(ShaCacheMixin, ERP5TypeTestCase):
transaction.commit() transaction.commit()
self.tic() self.tic()
def postFile(self, key=None): def putFile(self, key=None):
""" """
Post the file Post the file
""" """
...@@ -68,11 +69,13 @@ class TestShaCache(ShaCacheMixin, ERP5TypeTestCase): ...@@ -68,11 +69,13 @@ class TestShaCache(ShaCacheMixin, ERP5TypeTestCase):
data_file.seek(0) data_file.seek(0)
self.portal.changeSkin('SHACACHE') self.portal.changeSkin('SHACACHE')
self.shacache.REQUEST.set('method', 'POST') path = self.shacache.getPath()
self.shacache.REQUEST.set('Content-Type', 'application/json') response = self.publish('%s/%s' % (path, key),
self.shacache.REQUEST._file = data_file request_method='PUT',
self.shacache.WebSection_getDocumentValue(key) stdin=data_file,
basic='ERP5TypeTestCase:')
self.stepTic() self.stepTic()
self.assertEqual(response.getStatus(), httplib.CREATED)
finally: finally:
data_file.close() data_file.close()
...@@ -88,11 +91,11 @@ class TestShaCache(ShaCacheMixin, ERP5TypeTestCase): ...@@ -88,11 +91,11 @@ class TestShaCache(ShaCacheMixin, ERP5TypeTestCase):
self.shacache.REQUEST.set('method', 'GET') self.shacache.REQUEST.set('method', 'GET')
return self.shacache.WebSection_getDocumentValue(key) return self.shacache.WebSection_getDocumentValue(key)
def test_post_file(self): def test_put_file(self):
""" """
Check if the posted file has all the properties defined. Check if the PUT method is creating an object.
""" """
self.postFile() self.putFile()
self.assertEquals(1, len(self.portal.document_module)) self.assertEquals(1, len(self.portal.document_module))
document = self.portal.document_module.contentValues()[0] document = self.portal.document_module.contentValues()[0]
...@@ -100,12 +103,13 @@ class TestShaCache(ShaCacheMixin, ERP5TypeTestCase): ...@@ -100,12 +103,13 @@ class TestShaCache(ShaCacheMixin, ERP5TypeTestCase):
self.assertEquals(self.key, document.getReference()) self.assertEquals(self.key, document.getReference())
self.assertEquals(self.data, document.getData()) self.assertEquals(self.data, document.getData())
self.assertEquals('application/octet-stream', document.getContentType()) self.assertEquals('application/octet-stream', document.getContentType())
self.assertEquals('Published', document.getValidationStateTitle())
def test_get_file(self): def test_get_file(self):
""" """
Check if the file returned is the correct. Check if the file returned is the correct.
""" """
self.test_post_file() self.test_put_file()
self.assertEquals(1, len(self.portal.document_module)) self.assertEquals(1, len(self.portal.document_module))
document = self.getFile() document = self.getFile()
......
38 39
\ 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