Back to index

plone3  3.1.7
Classes | Functions | Variables
ATContentTypes.tests.test_attopic Namespace Reference

Classes

class  TestSiteATTopic
class  TestATTopicFields
class  TestATTopicFunctional

Functions

def editATCT
def convert_old_catalog_usage
def convert_old_catalog_query
def test_suite

Variables

string __author__ = 'Alec Mitchell'
string __docformat__ = 'restructuredtext'
 ACQUIRE = True
 LIMIT = False
string COUNT = '150'
 CUSTOM = True
tuple FIELDS = ('start','end', 'Creator')
dictionary CRITERIA_SETUP
dictionary CRIT_MAP
tuple REV_CRIT_MAP = dict([[v,k] for k,v in CRIT_MAP.items()])
list tests = []

Function Documentation

Convert old style query to new record based query

Definition at line 132 of file test_attopic.py.

00132 
00133 def convert_old_catalog_query(query):
00134     """Convert old style query to new record based query"""
00135     for k,v in query.items():
00136         q_field = q_type = q_param = None
00137         if '_usage' in k:
00138             q_field = k.replace('_usage','')
00139             usage = v.split(':')
00140             q_type = usage[0].strip()
00141             q_param = ':'.join(usage[1:]).strip()
00142         elif '_operator' in k:
00143             q_field = k.replace('_operator','')
00144             q_type = 'operator'
00145             q_param = v
00146         if q_field:
00147             new_val = query[q_field]
00148             if not isinstance(v, dict):
00149                 new_val = { 'query' : new_val }
00150             new_val[q_type] = q_param
00151             query[q_field] = new_val
00152             del query[k]
00153     return query

Here is the call graph for this function:

Convert old style query parameters into records

Definition at line 117 of file test_attopic.py.

00117 
00118 def convert_old_catalog_usage(criteria_items):
00119     """Convert old style query parameters into records"""
00120     if len(criteria_items) > 1:
00121         field = criteria_items[0][0]
00122         query_val = criteria_items[0][1]
00123         extra_param = criteria_items[1][1]
00124         if '_usage' in criteria_items[1][0]:
00125             usage = extra_param.split(':')
00126             extra_type = usage[0].strip()
00127             extra_param = ':'.join(usage[1:]).strip()
00128         else:
00129             extra_type = criteria_items[1][0].replace('%s_'%field,'')
00130         criteria_items = [(field, {'query': query_val, extra_type: extra_param})]
00131     return tuple(criteria_items)

Here is the call graph for this function:

Definition at line 85 of file test_attopic.py.

00085 
00086 def editATCT(obj):
00087     dcEdit(obj)
00088     obj.setAcquireCriteria(ACQUIRE)
00089     obj.setLimitNumber(LIMIT)
00090     obj.setItemCount(COUNT)
00091     #obj.setCustomView(CUSTOM)
00092     #obj.setCustomViewFields(FIELDS)
00093     for meta in CRITERIA_SETUP.keys():
00094         AT_META = CRIT_MAP[meta]
00095         CRIT_FIELD = CRITERIA_SETUP[meta][0]
00096         obj.addCriterion(CRIT_FIELD, AT_META)
00097     for crit in obj.listCriteria():
00098         CRIT_TYPE = crit.meta_type
00099         OLD_CRIT_TYPE = REV_CRIT_MAP[CRIT_TYPE]
00100         params = CRITERIA_SETUP[OLD_CRIT_TYPE][1:]
00101         if CRIT_TYPE not in ['ATSortCriterion','ATSimpleIntCriterion']:
00102             crit.setValue(params[0])
00103         if CRIT_TYPE == 'ATFriendlyDateCriteria':
00104             crit.setOperation(params[1])
00105             DATE_RANGE = (params[2] == 'ahead' and '+') or '-'
00106             crit.setDateRange(DATE_RANGE)
00107         if CRIT_TYPE == 'ATListCriterion':
00108             crit.setOperator(params[1])
00109         if CRIT_TYPE == 'ATSimpleIntCriterion':
00110             value = params[0].split(' ')
00111             crit.setValue(value[0])
00112             if len(value) > 1:
00113                 crit.setValue2(value[1])
00114             crit.setDirection(params[1])
00115         if CRIT_TYPE == 'ATSortCriterion':
00116             crit.setReversed(params[0])

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 585 of file test_attopic.py.

00585 
00586 def test_suite():
00587     suite = unittest.TestSuite()
00588     for test in tests:
00589         suite.addTest(unittest.makeSuite(test))
00590     return suite

Variable Documentation

Definition at line 22 of file test_attopic.py.

Definition at line 23 of file test_attopic.py.

Definition at line 50 of file test_attopic.py.

Definition at line 52 of file test_attopic.py.

Initial value:
00001 {'Integer Criterion': 'ATSimpleIntCriterion',
00002             'String Criterion': 'ATSimpleStringCriterion',
00003             'Friendly Date Criterion': 'ATFriendlyDateCriteria',
00004             'List Criterion': 'ATListCriterion',
00005             'Sort Criterion': 'ATSortCriterion'}

Definition at line 77 of file test_attopic.py.

Initial value:
00001 {'Integer Criterion':      #Meta Type
00002                         ('portal_type',     #Field
00003                          '10 10',            #Value
00004                          'min:max'),        #Direction
00005                   'String Criterion':
00006                         ('SearchableText',
00007                          'portal'),
00008                   'Friendly Date Criterion':
00009                         ('start',
00010                          '10',
00011                          'within_day',       #Operation
00012                          'ahead'),          #DateRange
00013                   'List Criterion':
00014                         ('Subject',
00015                          "value1\nportal\ntest",
00016                          'OR'),             #Operator
00017                   'Sort Criterion':
00018                         ('getId',
00019                          False),            #Reversed
00020                 }

Definition at line 56 of file test_attopic.py.

Definition at line 53 of file test_attopic.py.

tuple ATContentTypes.tests.test_attopic.FIELDS = ('start','end', 'Creator')

Definition at line 54 of file test_attopic.py.

Definition at line 51 of file test_attopic.py.

tuple ATContentTypes.tests.test_attopic.REV_CRIT_MAP = dict([[v,k] for k,v in CRIT_MAP.items()])

Definition at line 83 of file test_attopic.py.

Definition at line 154 of file test_attopic.py.