Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
kupu.plone.tests.test_html2captioned.TransformTest Class Reference
Inheritance diagram for kupu.plone.tests.test_html2captioned.TransformTest:
Inheritance graph
[legend]
Collaboration diagram for kupu.plone.tests.test_html2captioned.TransformTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def do_convert
def testSame
def testSameNoFilename
def __repr__
def afterSetUp
def loginPortalOwner
def create
def setup_content

Public Attributes

 kupu

Detailed Description

Definition at line 37 of file test_html2captioned.py.


Member Function Documentation

Definition at line 83 of file test_html2captioned.py.

00083 
00084     def __repr__(self):
00085         return self.transform.name()

Definition at line 55 of file kuputestcase.py.

00055 
00056     def afterSetUp(self):
00057         portal = self.portal
00058         self.setRoles(['Manager',])
00059         self.kupu = portal.kupu_library_tool
00060         self.kupu.configure_kupu(captioning=True, linkbyuid=True)
00061         typestool = self.portal.portal_types
00062         if not hasattr(typestool, 'ATDocument'):
00063             # Use the type names without the AT prefix
00064             for k in TypeMapping:
00065                 TypeMapping[k] = k

Here is the call graph for this function:

def kupu.plone.tests.kuputestcase.KupuTestCase.create (   self,
  id,
  metatype = 'ATDocument',
  folder = None,
  kwds 
) [inherited]
Create an object in the cms portal

Definition at line 72 of file kuputestcase.py.

00072 
00073     def create(self, id, metatype='ATDocument', folder=None, **kwds):
00074         '''Create an object in the cms portal'''
00075         if folder is None:
00076             folder = self.portal
00077 
00078         folder.invokeFactory(MapType(metatype), id)
00079         obj = getattr(folder, id)
00080 
00081         if metatype=='Folder' and constraintypes:
00082             obj.setConstrainTypesMode(constraintypes.DISABLED)
00083 
00084         if metatype=='Document':
00085             obj.setTitle('Simple document')
00086             obj.setText('Sample document text')
00087             for k, v in kwds.items():
00088                 field = obj.getField(k)
00089                 mutator = field.getMutator(obj)(v)
00090 
00091             obj.reindexObject()
00092 
00093         assert obj is not None
00094         return obj

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 38 of file test_html2captioned.py.

00038 
00039     def do_convert(self, filename=None):
00040         if filename is None and exists(self.output + '.nofilename'):
00041             output = self.output + '.nofilename'
00042         else:
00043             output = self.output
00044         input = open(self.input)
00045         orig = input.read()
00046         input.close()
00047         data = datastream(self.transform.name())
00048         res_data = self.transform.convert(orig, data, filename=filename, context=self.portal)
00049         if IDataStream is not None:
00050             self.assert_(IDataStream.providedBy(res_data))
00051         got = res_data.getData()
00052         try:
00053             output = open(output)
00054         except IOError:
00055             import sys
00056             print >>sys.stderr, 'No output file found.'
00057             print >>sys.stderr, 'File %s created, check it !' % self.output
00058             output = open(output, 'w')
00059             output.write(got)
00060             output.close()
00061             self.assert_(0)
00062         expected = output.read()
00063         raw_got, raw_expected = got, expected
00064         if self.normalize is not None:
00065             expected = self.normalize(expected)
00066             got = self.normalize(got)
00067         output.close()
00068 
00069         self.assertEquals(got, expected,
00070                           'Got:\n[%s]\n\n!=\n\nExpected:\n[%s]\n\nIN %s(%s)' % (
00071             got, expected, self.transform.name(), self.input))
00072         self.assertEquals(self.subobjects, len(res_data.getSubObjects()),
00073                           'Subobjects:\n%s\n\n!=\n\nLength: %s\n\nIN %s(%s)' % (
00074             self.subobjects, len(res_data.getSubObjects()), self.transform.name(), self.input))

Here is the call graph for this function:

Here is the caller graph for this function:

Use if you need to manipulate the portal itself.

Definition at line 66 of file kuputestcase.py.

00066 
00067     def loginPortalOwner(self):
00068         '''Use if you need to manipulate the portal itself.'''
00069         uf = self.app.acl_users
00070         user = uf.getUserById(portal_owner).__of__(uf)
00071         newSecurityManager(None, user)

Here is the caller graph for this function:

Definition at line 95 of file kuputestcase.py.

00095 
00096     def setup_content(self):
00097         self.setRoles(['Manager',])
00098         self.loginPortalOwner()
00099         f = self.create('folder', 'Folder')
00100 
00101         for id in ('alpha', 'beta'):
00102             self.create(id, 'Document', f, subject=['aspidistra'])
00103         self.create('gamma', 'Image', f)
00104         gamma = f.gamma
00105         gamma.setImage(open(join(PREFIX,'image.jpg'),'rb').read())
00106         gamma.setTitle('Kupu Test Image')
00107         gamma.setDescription('Test image caption')
00108         # The image needs a fixed uid for the transform tests.
00109         f.gamma._setUID('104ede98d4c7c8eaeaa3b984f7395979')
00110 
00111         self.create('umlauts', 'Image', f)
00112         umlauts = f.umlauts
00113         umlauts.setImage(open(join(PREFIX,'image.jpg'),'rb').read())
00114         title, description = open(join(PREFIX, 'umlauts-testdata.txt')).read().strip().split(';')
00115         umlauts.setTitle(title)
00116         umlauts.setDescription(description)
00117         # The image needs a fixed uid for the transform tests.
00118         f.umlauts._setUID('215fef98e5d7c9ebebb4c984f7395979')
00119 
00120         f.reindexObject()
00121 
00122         sub1 = self.create('sub1', 'Folder', f)
00123         sub1.setSubject(['aspidistra'])
00124         sub1.reindexObject()
00125         sub2 = self.create('sub2', 'Folder', f)
00126         self.create('delta', 'Folder', sub2)
00127 
00128         portal = self.portal
00129         tool = self.portal.kupu_library_tool
00130         types = tool.zmi_get_resourcetypes()
00131         #tool.deleteResource([ t.name for t in types])
00132         for k,v in RESOURCES.items():
00133             tool.addResourceType(k, [MapType(t) for t in v])

Here is the caller graph for this function:

Definition at line 75 of file test_html2captioned.py.

00075 
00076     def testSame(self):
00077         self.setup_content()
00078         self.do_convert(filename=self.input)

Here is the call graph for this function:

Definition at line 79 of file test_html2captioned.py.

00079 
00080     def testSameNoFilename(self):
00081         self.setup_content()
00082         self.do_convert()

Here is the call graph for this function:


Member Data Documentation

Definition at line 58 of file kuputestcase.py.


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