Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
Marshall.tests.test_predicate.DefaultPredicateTest Class Reference
Inheritance diagram for Marshall.tests.test_predicate.DefaultPredicateTest:
Inheritance graph
[legend]
Collaboration diagram for Marshall.tests.test_predicate.DefaultPredicateTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_expression_filename
def test_expression_content_type
def test_expression_data
def afterSetUp
def get
def reverse

Public Attributes

 qi
 tool

Detailed Description

Definition at line 56 of file test_predicate.py.


Member Function Documentation

Definition at line 41 of file test_predicate.py.

00041 
00042     def afterSetUp(self):
00043         super(PredicateTest, self).afterSetUp()
00044         self.loginPortalOwner()
00045         self.qi = self.portal.portal_quickinstaller
00046         self.qi.installProduct('Marshall')
00047         self.tool = getToolByName(self.portal, tool_id)

Here is the call graph for this function:

def Marshall.tests.test_predicate.PredicateTest.get (   self,
  obj,
  kw 
) [inherited]

Definition at line 48 of file test_predicate.py.

00048 
00049     def get(self, obj, **kw):
00050         return self.tool.getMarshallersFor(obj, **kw)

Here is the caller graph for this function:

Definition at line 51 of file test_predicate.py.

00051 
00052     def reverse(self):
00053         ids = self.tool.objectIds()
00054         for pos, id in enumerate(ids):
00055             self.tool.moveObjectToPosition(id, len(ids) - pos)

Here is the caller graph for this function:

Definition at line 93 of file test_predicate.py.

00093 
00094     def test_expression_content_type(self):
00095         add_predicate(
00096             self.tool, id='text_xml',
00097             title='text/xml content type',
00098             predicate='default',
00099             expression="python: content_type and content_type == 'text/xml'",
00100             component_name='simple_xml')
00101         add_predicate(
00102             self.tool,
00103             id='text_plain',
00104             title='text/plain content type',
00105             predicate='default',
00106             expression="python: content_type and content_type == 'text/plain'",
00107             component_name='rfc822')
00108         add_predicate(
00109             self.tool,
00110             id='default',
00111             title='default',
00112             predicate='default',
00113             expression="",
00114             component_name='primary_field')
00115 
00116         self.assertEquals(
00117             self.get(None, content_type='text/xml'),
00118             ('simple_xml', 'primary_field'))
00119         self.assertEquals(self.get(None, content_type='text/plain'),
00120                           ('rfc822', 'primary_field'))
00121 
00122         # Make sure reordering the predicates does change the order
00123         # in which ids are returned.
00124         self.reverse()
00125         self.assertEquals(self.get(None, content_type='text/plain'),
00126                           ('primary_field', 'rfc822'))
00127 
00128         # Make sure it works even if no content_type kw is passed in
00129         self.assertEquals(self.get(None), ('primary_field',))

Definition at line 130 of file test_predicate.py.

00130 
00131     def test_expression_data(self):
00132         add_predicate(
00133             self.tool,
00134             id='data_len_3',
00135             title='data length > 3',
00136             predicate='default',
00137             expression="python: data and len(data) > 3",
00138             component_name='primary_field')
00139         add_predicate(
00140             self.tool,
00141             id='data_len_2',
00142             title='data length == 2',
00143             predicate='default',
00144             expression="python: data and len(data) == 2",
00145             component_name='rfc822')
00146         add_predicate(
00147             self.tool,
00148             id='default',
00149             title='default',
00150             predicate='default',
00151             expression='',
00152             component_name='primary_field')
00153         self.assertEquals(self.get(None, data='4242'), ('primary_field',))
00154         self.assertEquals(self.get(None, data='42'), ('rfc822', 'primary_field'))
00155 
00156         # Make sure reordering the predicates does change the order
00157         # in which ids are returned.
00158         self.reverse()
00159         self.assertEquals(self.get(None, data='42'), ('primary_field', 'rfc822'))
00160 
00161         # Make sure it works even if no data kw is passed in
00162         self.assertEquals(self.get(None), ('primary_field',))
00163 

Definition at line 58 of file test_predicate.py.

00058 
00059     def test_expression_filename(self):
00060         add_predicate(self.tool, id='doc',
00061                       title='.doc extension',
00062                       predicate='default',
00063                       expression="python: filename and filename.endswith('.doc')",
00064                       component_name='primary_field')
00065         add_predicate(self.tool, id='txt',
00066                       title='.txt extension',
00067                       predicate='default',
00068                       expression="python: filename and filename.endswith('.txt')",
00069                       component_name='rfc822')
00070         add_predicate(self.tool, id='default',
00071                       title='default',
00072                       predicate='default',
00073                       expression='',
00074                       component_name='primary_field')
00075 
00076         self.assertEquals(
00077             self.get(None, filename='sample.doc'), ('primary_field',))
00078         self.assertEquals(
00079             self.get(None, filename='sample.txt'),
00080             ('rfc822', 'primary_field'))
00081 
00082         # Make sure reordering the predicates does change the order
00083         # in which ids are returned.
00084         self.reverse()
00085         self.assertEquals(
00086             self.get(None, filename='sample.txt'),
00087             ('primary_field', 'rfc822'))
00088 
00089         self.assertEquals(self.get(None, filename='sample.rot'),
00090                           ('primary_field',))
00091         # Make sure it works even if no filename kw is passed in
00092         self.assertEquals(self.get(None), ('primary_field',))


Member Data Documentation

Definition at line 44 of file test_predicate.py.

Definition at line 46 of file test_predicate.py.


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