Back to index

plone3  3.1.7
Public Member Functions
Archetypes.tests.test_marshaller.MarshallerTests Class Reference
Inheritance diagram for Archetypes.tests.test_marshaller.MarshallerTests:
Inheritance graph
[legend]
Collaboration diagram for Archetypes.tests.test_marshaller.MarshallerTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def XXX_test_textFieldObjectWordReplace
def test_textFieldObjectRSTreplace
def test_fileFieldObjectWordReplace
def setupCTR
def XXX_test_objectCreate

Detailed Description

Definition at line 42 of file test_marshaller.py.


Member Function Documentation

Definition at line 103 of file test_marshaller.py.

00103 
00104     def setupCTR(self):
00105         #Modify the CTR to point to SimpleType
00106         ctr = self.portal.content_type_registry
00107         if ctr.getPredicate('text'):
00108             # ATCT has a predict
00109             ctr.removePredicate('text')
00110         ctr.addPredicate('text', 'major_minor' )
00111         ctr.getPredicate('text' ).edit('text', '' )
00112         ctr.assignTypeName('text', 'DDocument')
00113         ctr.reorderPredicate('text', 0)
00114 
00115         ctr.addPredicate('msword', 'major_minor' )
00116         ctr.getPredicate('msword' ).edit( 'application', 'msword' )
00117         ctr.assignTypeName('msword', 'DDocument')
00118         ctr.reorderPredicate('msword', 1)
00119 
00120         return ctr

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 85 of file test_marshaller.py.

00085 
00086     def test_fileFieldObjectWordReplace(self):
00087         #test that uploading to an existing object works
00088         obj1 = makeContent(self.folder, portal_type='SimpleFile', id='obj1')
00089 
00090         wordFilePath = os.path.join(PACKAGE_HOME, "input", "word.doc")
00091         wordFile = open(wordFilePath, 'r')
00092         data = wordFile.read()
00093         wordFile.seek(0)
00094 
00095         request = aputrequest(wordFile, 'application/msword')
00096         request.processInputs()
00097         word = self.folder.obj1
00098         word.PUT(request, request.RESPONSE)
00099 
00100         #and we can get the stuff back
00101         self.assertEqual(word.getContentType('body'), 'application/msword')
00102         self.assertEqual(str(word.getRawBody()), data)

Here is the call graph for this function:

Definition at line 65 of file test_marshaller.py.

00065 
00066     def test_textFieldObjectRSTreplace(self):
00067         ## And again with an RST
00068         obj1 = makeContent(self.folder, portal_type='DDocument', id='obj1')
00069 
00070         rstFilePath = os.path.join(PACKAGE_HOME, "input", "rest1.rst")
00071         rstFile = open(rstFilePath, 'r')
00072         data = rstFile.read()
00073         rstFile.seek(0)
00074 
00075         request = aputrequest(rstFile, 'text/x-rst')
00076         # XXX PUT factory is using PARENTS to get an acquisition context
00077         request['PARENTS'] = (self.folder, self.portal)
00078         request.processInputs()
00079         rst = self.folder.obj1
00080         rst.PUT(request, request.RESPONSE)
00081 
00082         #and we can get the stuff back
00083         self.assertEqual(rst.getContentType('body'), 'text/x-rst')
00084         self.assertEqual(rst.getRawBody().strip(), data.strip())

Here is the call graph for this function:

Definition at line 122 of file test_marshaller.py.

00122 
00123     def XXX_test_objectCreate(self):
00124         #create the correct object on upload
00125         #one day, but this will need a change to the factory
00126         ctr = self.setupCTR()
00127 
00128         #now trigger the creation of a content type akin to DAV
00129         wordFilePath = os.path.join(PACKAGE_HOME, "input", "word.doc")
00130         wordFile = open(wordFilePath, 'r')
00131 
00132         obj = self.folder.PUT_factory('test', 'application/msword', wordFile)
00133         self.folder._setObject('test', obj)
00134         word = self.folder.test
00135 
00136         request = aputrequest(wordFile, 'application/msword')
00137         request.processInputs()
00138         word.PUT(request, request.RESPONSE)
00139 
00140         wordFile.seek(0)
00141         data = wordFile.read()
00142 
00143         self.assertEqual(word.archetype_name, DDocument.archetype_name)
00144         self.assertEqual(str(word.getBody(raw=1)), data)
00145         self.assertEqual(word.getContentType('body'), 'application/msword')

Here is the call graph for this function:

Definition at line 45 of file test_marshaller.py.

00045 
00046     def XXX_test_textFieldObjectWordReplace(self):
00047         #test that uploading to an existing object works
00048         obj1 = makeContent(self.folder, portal_type='DDocument', id='obj1')
00049 
00050         wordFilePath = os.path.join(PACKAGE_HOME, "input", "word.doc")
00051         wordFile = open(wordFilePath, 'r')
00052         data = wordFile.read()
00053         wordFile.seek(0)
00054 
00055         # put requests don't have the luxury of being able to specify a
00056         # content type
00057         request = aputrequest(wordFile, 'application/msword')
00058         request.processInputs()
00059         word = self.folder.obj1
00060         word.PUT(request, request.RESPONSE)
00061 
00062         #and we can get the stuff back
00063         self.assertEqual(word.getContentType('body'), 'application/msword')
00064         self.assertEqual(word.getRawBody(), data)

Here is the call graph for this function:


The documentation for this class was generated from the following file: