Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
ATContentTypes.tests.test_topictool.TestTool Class Reference
Inheritance diagram for ATContentTypes.tests.test_topictool.TestTool:
Inheritance graph
[legend]
Collaboration diagram for ATContentTypes.tests.test_topictool.TestTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def test_interface
def test_Z3interface
def test_add_index
def test_disable_index
def test_add_bogus_index
def test_remove_index
def test_update_index
def test_all_indexes
def test_change_catalog_index
def test_add_metadata
def test_disable_metadata
def test_add_bogus_metadata
def test_remove_metadata
def test_update_metadata
def test_all_metadata
def test_change_catalog_schema

Public Attributes

 tool

Detailed Description

Definition at line 26 of file test_topictool.py.


Member Function Documentation

Definition at line 28 of file test_topictool.py.

00028 
00029     def afterSetUp(self):
00030         self.tool = getattr(self.portal.aq_explicit, TOOLNAME)

Definition at line 78 of file test_topictool.py.

00078 
00079     def test_add_bogus_index(self):
00080         # You can add metadata that's not in the catalog
00081         t = self.tool
00082         t.addIndex('bogosity', enabled = True)
00083         self.failUnless(t.getIndex('bogosity'))
00084         
00085         #Add
00086         t.addIndex('bogosity', enabled = True)
00087         self.failUnless('bogosity' in [a[0] for a in t.getEnabledFields()])
00088         #Add
00089         t.addIndex('bogosity', enabled = True)
00090         self.failUnless('bogosity' in t.getIndexDisplay(True).keys())
00091         #Add
00092         t.addIndex('bogosity', enabled = True)
00093         self.failUnless('bogosity' in t.getIndexes(1))
00094         #Add
00095         t.addIndex('bogosity', enabled = True)
00096         self.failUnless('bogosity' in [i.index for i in t.getEnabledIndexes()])
        

Definition at line 195 of file test_topictool.py.

00195 
00196     def test_add_bogus_metadata(self):
00197         # You can add metdata that's not in the catalog
00198         t = self.tool
00199         t.addMetadata('bogosity', enabled = True)
00200         self.failUnless(t.getMetadata('bogosity'))
00201 
00202         #Add
00203         t.addMetadata('bogosity', enabled = True)
00204         self.failUnless('bogosity' in t.getMetadataDisplay(True).keys())
00205         #Add
00206         t.addMetadata('bogosity', enabled = True)
00207         self.failUnless('bogosity' in t.getAllMetadata(1))
00208         #Add
00209         t.addMetadata('bogosity', enabled = True)
00210         self.failUnless('bogosity' in [i.index for i in t.getEnabledMetadata()])

Definition at line 40 of file test_topictool.py.

00040 
00041     def test_add_index(self):
00042         t = self.tool
00043         t.addIndex(enabled = True, **index_def)
00044         index = t.getIndex(index_def['index'])
00045         self.failUnlessEqual(index.index, index_def['index'])
00046         self.failUnlessEqual(index.friendlyName, index_def['friendlyName'])
00047         self.failUnlessEqual(index.description, index_def['description'])
00048         # Only need to test truth not actual value
00049         self.failUnless(index.enabled)
00050         self.failUnlessEqual(index.criteria, tuple(index_def['criteria']))
00051 
00052         self.failUnless(index in t.getEnabledIndexes())
00053         self.failUnless(index_def['index'] in [a[0] for a in t.getEnabledFields()])
00054         self.failUnless(index_def['index'] in t.getIndexDisplay(True).keys())
00055         self.failUnless(index_def['friendlyName'] in t.getIndexDisplay(True).values())
00056         self.failUnless(index_def['index'] in t.getIndexes(1))
        

Here is the call graph for this function:

Definition at line 161 of file test_topictool.py.

00161 
00162     def test_add_metadata(self):
00163         t = self.tool
00164         t.addMetadata(enabled = True, **meta_def)
00165         meta = t.getMetadata(meta_def['metadata'])
00166         self.failUnlessEqual(meta.index, meta_def['metadata'])
00167         self.failUnlessEqual(meta.friendlyName, meta_def['friendlyName'])
00168         self.failUnlessEqual(meta.description, meta_def['description'])
00169         # Only need to test truth not actual value
00170         self.failUnless(meta.enabled)
00171 
00172         self.failUnless(meta in t.getEnabledMetadata())
00173         self.failUnless(meta_def['metadata'] in t.getMetadataDisplay(True).keys())
00174         self.failUnless(meta_def['friendlyName'] in t.getMetadataDisplay(True).values())
00175         self.failUnless(meta_def['metadata'] in t.getAllMetadata(1))
        

Here is the call graph for this function:

Definition at line 130 of file test_topictool.py.

00130 
00131     def test_all_indexes(self):
00132         # Ensure that the tool includes all indexes in the catalog
00133         t = self.tool
00134         cat = getToolByName(self.tool, CatalogTool.id)
00135         indexes = [field for field in cat.indexes()]
00136         init_indexes = list(t.getIndexes())
00137         unique_indexes = [i for i in indexes if i not in init_indexes]
00138         unique_indexes = unique_indexes + [i for i in init_indexes if i not in indexes]
00139         self.failIf(unique_indexes)

Here is the call graph for this function:

Definition at line 239 of file test_topictool.py.

00239 
00240     def test_all_metadata(self):
00241         # Ensure that the tool includes all metadata in the catalog
00242         t = self.tool
00243         cat = getToolByName(self.tool, CatalogTool.id)
00244         metadata = [field for field in cat.schema()]
00245         init_metadata = list(t.getAllMetadata())
00246         unique_metadata = [i for i in metadata if i not in init_metadata]
00247         unique_metadata = unique_metadata + [i for i in init_metadata if i not in metadata]
00248         self.failIf(unique_metadata)

Here is the call graph for this function:

Definition at line 140 of file test_topictool.py.

00140 
00141     def test_change_catalog_index(self):
00142         t = self.tool
00143         cat = getToolByName(self.tool, CatalogTool.id)
00144         #add
00145         error = True
00146         cat.manage_addIndex('nonsense', 'FieldIndex')
00147         try:
00148             t.getIndex('nonsense')
00149         except AttributeError:
00150             error = False
00151         self.failIf(error)
00152         #remove
00153         error = False
00154         cat.delIndex('nonsense')
00155         try:
00156             t.getIndex('nonsense')
00157         except AttributeError:
00158             error = True
00159         self.failUnless(error)

Here is the call graph for this function:

Definition at line 249 of file test_topictool.py.

00249 
00250     def test_change_catalog_schema(self):
00251         t = self.tool
00252         cat = getToolByName(self.tool, CatalogTool.id)
00253         #add
00254         error = True
00255         cat.manage_addColumn('nonsense')
00256         try:
00257             t.getMetadata('nonsense')
00258         except AttributeError:
00259             error = False
00260         self.failIf(error)
00261         #remove
00262         error = False
00263         cat.delColumn('nonsense')
00264         try:
00265             t.getMetadata('nonsense')
00266         except AttributeError:
00267             error = True
00268         self.failUnless(error)
00269 
00270 tests.append(TestTool)

Here is the call graph for this function:

Definition at line 57 of file test_topictool.py.

00057 
00058     def test_disable_index(self):
00059         t = self.tool
00060         t.addIndex(enabled = False, **index_def)
00061         index = t.getIndex(index_def['index'])
00062         self.failUnlessEqual(index.index, index_def['index'])
00063         self.failUnlessEqual(index.friendlyName, index_def['friendlyName'])
00064         self.failUnlessEqual(index.description, index_def['description'])
00065         # Only need to test truth not actual value
00066         self.failIf(index.enabled)
00067         self.failUnlessEqual(index.criteria, tuple(index_def['criteria']))
00068 
00069         self.failIf(index in t.getEnabledIndexes())
00070         self.failIf(index_def['index'] in [a[0] for a in t.getEnabledFields()])
00071         self.failIf(index_def['index'] in t.getIndexes(1))
00072         self.failIf(index_def['index'] in t.getIndexDisplay(True).keys())
00073         self.failUnless(index_def['friendlyName'] not in t.getIndexDisplay(True).values())
00074         # Make sure it's still in the un-limited list
00075         self.failUnless(index_def['index'] in t.getIndexDisplay(False).keys())
00076         self.failUnless(index_def['friendlyName'] in t.getIndexDisplay(False).values())
00077         self.failUnless(index_def['index'] in t.getIndexes())

Here is the call graph for this function:

Definition at line 176 of file test_topictool.py.

00176 
00177     def test_disable_metadata(self):
00178         t = self.tool
00179         t.addMetadata(enabled = False, **meta_def)
00180         meta = t.getMetadata(meta_def['metadata'])
00181         self.failUnlessEqual(meta.index, meta_def['metadata'])
00182         self.failUnlessEqual(meta.friendlyName, meta_def['friendlyName'])
00183         self.failUnlessEqual(meta.description, meta_def['description'])
00184         # Only need to test truth not actual value
00185         self.failIf(meta.enabled)
00186 
00187         self.failUnless(meta not in t.getEnabledMetadata())
00188         self.failIf(meta_def['metadata'] in t.getAllMetadata(1))
00189         self.failIf(meta_def['metadata'] in t.getMetadataDisplay(True).keys())
00190         self.failIf(meta_def['friendlyName'] in t.getMetadataDisplay(True).values())
00191         # Make sure it's still in the un-limited list
00192         self.failUnless(meta_def['metadata'] in t.getMetadataDisplay(False).keys())
00193         self.failUnless(meta_def['friendlyName'] in t.getMetadataDisplay(False).values())
00194         self.failUnless(meta_def['metadata'] in t.getAllMetadata())

Here is the call graph for this function:

Definition at line 31 of file test_topictool.py.

00031 
00032     def test_interface(self):
00033         self.failUnless(IATCTTopicsTool.isImplementedBy(self.tool))
00034         self.failUnless(verifyObject(IATCTTopicsTool, self.tool))

Definition at line 97 of file test_topictool.py.

00097 
00098     def test_remove_index(self):
00099         t = self.tool
00100         t.addIndex(**index_def)
00101         t.removeIndex(index_def['index'])
00102         error = None
00103         try:
00104             index = t.topic_indexes[index_def['index']]
00105         except KeyError:
00106             error = True
00107         self.failUnless(error)
00108 
00109         error = True
00110         try:
00111             index = t.getIndex(index_def['index'])
00112         except AttributeError:
00113             error = False
00114         self.failIf(error)
        

Definition at line 211 of file test_topictool.py.

00211 
00212     def test_remove_metadata(self):
00213         t = self.tool
00214         t.addMetadata(**meta_def)
00215         t.removeMetadata(meta_def['metadata'])
00216         error = None
00217         try:
00218             meta = t.topic_metadata[meta_def['metadata']]
00219         except KeyError:
00220             error = True
00221         self.failUnless(error)
00222 
00223         error = True
00224         try:
00225             meta = t.getMetadata(meta_def['metadata'])
00226         except AttributeError:
00227             error = False
00228         self.failIf(error)
        

Definition at line 115 of file test_topictool.py.

00115 
00116     def test_update_index(self):
00117         # An index with no criteria set should set all available criteria,
00118         # also changes made using updateIndex should not reset already set
00119         # values
00120         t = self.tool
00121         t.addIndex(enabled = True, **index_def)
00122         t.updateIndex(index_def['index'], criteria = None,
00123                       description = 'New Description')
00124         index = t.getIndex(index_def['index'])
00125         self.failUnless(index.criteria)
00126         self.failUnless(index.criteria != index_def['criteria'])
00127         self.failUnless(index.description == 'New Description')
00128         self.failUnless(index.friendlyName == index_def['friendlyName'])
00129         self.failUnless(index.enabled)

Definition at line 229 of file test_topictool.py.

00229 
00230     def test_update_metadata(self):
00231         # Changes made using updateMetadata should not reset already set
00232         # values
00233         t = self.tool
00234         t.addMetadata(enabled = True, **meta_def)
00235         t.updateMetadata(meta_def['metadata'], friendlyName = 'New Name')
00236         meta = t.getMetadata(meta_def['metadata'])
00237         self.failUnless(meta.friendlyName == 'New Name')
00238         self.failUnless(meta.enabled)

Definition at line 35 of file test_topictool.py.

00035 
00036     def test_Z3interface(self):
00037         iface = Z3IATCTTopicsTool
00038         self.failUnless(Z3verifyObject(iface,self.tool))
 

Member Data Documentation

Definition at line 29 of file test_topictool.py.


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