web/test/unittest_viewselector.py
changeset 2643 9976f511003b
parent 2458 4d114865098f
child 2650 18aec79ec3a3
equal deleted inserted replaced
2642:2d30de60a8ff 2643:9976f511003b
    72                               ('index', startup.IndexView),
    72                               ('index', startup.IndexView),
    73                               ('info', management.ProcessInformationView),
    73                               ('info', management.ProcessInformationView),
    74                               ('manage', startup.ManageView),
    74                               ('manage', startup.ManageView),
    75                               ('owl', owl.OWLView),
    75                               ('owl', owl.OWLView),
    76                               ('propertiesform', cwproperties.CWPropertiesForm),
    76                               ('propertiesform', cwproperties.CWPropertiesForm),
    77                               ('schema', startup.SchemaView),
    77                               ('schema', schema.SchemaView),
    78                               ('systempropertiesform', cwproperties.SystemCWPropertiesForm)])
    78                               ('systempropertiesform', cwproperties.SystemCWPropertiesForm)])
    79 
    79 
    80     def test_possible_views_noresult(self):
    80     def test_possible_views_noresult(self):
    81         rset, req = self.env.get_rset_and_req('Any X WHERE X eid 999999')
    81         rset, req = self.env.get_rset_and_req('Any X WHERE X eid 999999')
    82         self.assertListEqual(self.pviews(req, rset),
    82         self.assertListEqual(self.pviews(req, rset),
    83                              [])
    83                              [])
    84 
    84 
    85     def test_possible_views_one_egroup(self):
    85     def test_possible_views_one_egroup(self):
    86         rset, req = self.env.get_rset_and_req('CWGroup X WHERE X name "managers"')
    86         rset, req = self.env.get_rset_and_req('CWGroup X WHERE X name "managers"')
       
    87         self.assertListEqual(self.pviews(req, rset),
       
    88                              [('adaptedlist', baseviews.AdaptedListView),
       
    89                               ('csvexport', csvexport.CSVRsetView),
       
    90                               ('ecsvexport', csvexport.CSVEntityView),
       
    91                               ('editable-table', tableview.EditableTableView),
       
    92                               ('filetree', treeview.FileTreeView),
       
    93                               ('list', baseviews.ListView),
       
    94                               ('oneline', baseviews.OneLineView),
       
    95                               ('owlabox', owl.OWLABOXView),
       
    96                               ('primary', primary.PrimaryView),
       
    97                               ('rsetxml', xmlrss.XMLRsetView),
       
    98                               ('rss', xmlrss.RSSView),
       
    99                               ('secondary', baseviews.SecondaryView),
       
   100                               ('security', management.SecurityManagementView),
       
   101                               ('table', tableview.TableView),
       
   102                               ('text', baseviews.TextView),
       
   103                               ('treeview', treeview.TreeView),
       
   104                               ('xbel', xbel.XbelView),
       
   105                               ('xml', xmlrss.XMLView),
       
   106                               ])
       
   107 
       
   108     def test_possible_views_multiple_egroups(self):
       
   109         rset, req = self.env.get_rset_and_req('CWGroup X')
       
   110         self.assertListEqual(self.pviews(req, rset),
       
   111                              [('adaptedlist', baseviews.AdaptedListView),
       
   112                               ('csvexport', csvexport.CSVRsetView),
       
   113                               ('ecsvexport', csvexport.CSVEntityView),
       
   114                               ('editable-table', tableview.EditableTableView),
       
   115                               ('filetree', treeview.FileTreeView),
       
   116                               ('list', baseviews.ListView),
       
   117                               ('oneline', baseviews.OneLineView),
       
   118                               ('owlabox', owl.OWLABOXView),
       
   119                               ('primary', primary.PrimaryView),
       
   120                               ('rsetxml', xmlrss.XMLRsetView),
       
   121                               ('rss', xmlrss.RSSView),
       
   122                               ('secondary', baseviews.SecondaryView),
       
   123                               ('security', management.SecurityManagementView),
       
   124                               ('table', tableview.TableView),
       
   125                               ('text', baseviews.TextView),
       
   126                               ('treeview', treeview.TreeView),
       
   127                               ('xbel', xbel.XbelView),
       
   128                               ('xml', xmlrss.XMLView),
       
   129                               ])
       
   130 
       
   131     def test_propertiesform_admin(self):
       
   132         assert self.vreg['views']['propertiesform']
       
   133         rset1, req1 = self.env.get_rset_and_req('CWUser X WHERE X login "admin"')
       
   134         rset2, req2 = self.env.get_rset_and_req('CWUser X WHERE X login "anon"')
       
   135         self.failUnless(self.vreg.select('views', 'propertiesform', req1, rset=None))
       
   136         self.failUnless(self.vreg.select('views', 'propertiesform', req1, rset=rset1))
       
   137         self.failUnless(self.vreg.select('views', 'propertiesform', req2, rset=rset2))
       
   138 
       
   139     def test_propertiesform_anon(self):
       
   140         self.login('anon')
       
   141         rset1, req1 = self.env.get_rset_and_req('CWUser X WHERE X login "admin"')
       
   142         rset2, req2 = self.env.get_rset_and_req('CWUser X WHERE X login "anon"')
       
   143         self.assertRaises(NoSelectableObject, self.vreg.select, 'views', 'propertiesform', req1, rset=None)
       
   144         self.assertRaises(NoSelectableObject, self.vreg.select, 'views', 'propertiesform', req1, rset=rset1)
       
   145         self.assertRaises(NoSelectableObject, self.vreg.select, 'views', 'propertiesform', req1, rset=rset2)
       
   146 
       
   147     def test_propertiesform_jdoe(self):
       
   148         self.create_user('jdoe')
       
   149         self.login('jdoe')
       
   150         rset1, req1 = self.env.get_rset_and_req('CWUser X WHERE X login "admin"')
       
   151         rset2, req2 = self.env.get_rset_and_req('CWUser X WHERE X login "jdoe"')
       
   152         self.failUnless(self.vreg.select('views', 'propertiesform', req1, rset=None))
       
   153         self.assertRaises(NoSelectableObject, self.vreg.select, 'views', 'propertiesform', req1, rset=rset1)
       
   154         self.failUnless(self.vreg.select('views', 'propertiesform', req2, rset=rset2))
       
   155 
       
   156     def test_possible_views_multiple_different_types(self):
       
   157         rset, req = self.env.get_rset_and_req('Any X')
    87         self.assertListEqual(self.pviews(req, rset),
   158         self.assertListEqual(self.pviews(req, rset),
    88                              [('csvexport', csvexport.CSVRsetView),
   159                              [('csvexport', csvexport.CSVRsetView),
    89                               ('ecsvexport', csvexport.CSVEntityView),
   160                               ('ecsvexport', csvexport.CSVEntityView),
    90                               ('editable-table', tableview.EditableTableView),
   161                               ('editable-table', tableview.EditableTableView),
    91                               ('filetree', treeview.FileTreeView),
   162                               ('filetree', treeview.FileTreeView),
   102                               ('treeview', treeview.TreeView),
   173                               ('treeview', treeview.TreeView),
   103                               ('xbel', xbel.XbelView),
   174                               ('xbel', xbel.XbelView),
   104                               ('xml', xmlrss.XMLView),
   175                               ('xml', xmlrss.XMLView),
   105                               ])
   176                               ])
   106 
   177 
   107     def test_possible_views_multiple_egroups(self):
       
   108         rset, req = self.env.get_rset_and_req('CWGroup X')
       
   109         self.assertListEqual(self.pviews(req, rset),
       
   110                              [('csvexport', csvexport.CSVRsetView),
       
   111                               ('ecsvexport', csvexport.CSVEntityView),
       
   112                               ('editable-table', tableview.EditableTableView),
       
   113                               ('filetree', treeview.FileTreeView),
       
   114                               ('list', baseviews.ListView),
       
   115                               ('oneline', baseviews.OneLineView),
       
   116                               ('owlabox', owl.OWLABOXView),
       
   117                               ('primary', primary.PrimaryView),
       
   118                               ('rsetxml', xmlrss.XMLRsetView),
       
   119                               ('rss', xmlrss.RSSView),
       
   120                               ('secondary', baseviews.SecondaryView),
       
   121                               ('security', management.SecurityManagementView),
       
   122                               ('table', tableview.TableView),
       
   123                               ('text', baseviews.TextView),
       
   124                               ('treeview', treeview.TreeView),
       
   125                               ('xbel', xbel.XbelView),
       
   126                               ('xml', xmlrss.XMLView),
       
   127                               ])
       
   128 
       
   129     def test_propertiesform_admin(self):
       
   130         assert self.vreg['views']['propertiesform']
       
   131         rset1, req1 = self.env.get_rset_and_req('CWUser X WHERE X login "admin"')
       
   132         rset2, req2 = self.env.get_rset_and_req('CWUser X WHERE X login "anon"')
       
   133         self.failUnless(self.vreg.select_object('views', 'propertiesform', req1, rset=None))
       
   134         self.failUnless(self.vreg.select_object('views', 'propertiesform', req1, rset=rset1))
       
   135         self.failUnless(self.vreg.select_object('views', 'propertiesform', req2, rset=rset2))
       
   136 
       
   137     def test_propertiesform_anon(self):
       
   138         self.login('anon')
       
   139         rset1, req1 = self.env.get_rset_and_req('CWUser X WHERE X login "admin"')
       
   140         rset2, req2 = self.env.get_rset_and_req('CWUser X WHERE X login "anon"')
       
   141         self.assertRaises(NoSelectableObject, self.vreg.select_object, 'views', 'propertiesform', req1, rset=None)
       
   142         self.assertRaises(NoSelectableObject, self.vreg.select_object, 'views', 'propertiesform', req1, rset=rset1)
       
   143         self.assertRaises(NoSelectableObject, self.vreg.select_object, 'views', 'propertiesform', req1, rset=rset2)
       
   144 
       
   145     def test_propertiesform_jdoe(self):
       
   146         self.create_user('jdoe')
       
   147         self.login('jdoe')
       
   148         rset1, req1 = self.env.get_rset_and_req('CWUser X WHERE X login "admin"')
       
   149         rset2, req2 = self.env.get_rset_and_req('CWUser X WHERE X login "jdoe"')
       
   150         self.failUnless(self.vreg.select_object('views', 'propertiesform', req1, rset=None))
       
   151         self.assertRaises(NoSelectableObject, self.vreg.select_object, 'views', 'propertiesform', req1, rset=rset1)
       
   152         self.failUnless(self.vreg.select_object('views', 'propertiesform', req2, rset=rset2))
       
   153 
       
   154     def test_possible_views_multiple_different_types(self):
       
   155         rset, req = self.env.get_rset_and_req('Any X')
       
   156         self.assertListEqual(self.pviews(req, rset),
       
   157                              [('csvexport', csvexport.CSVRsetView),
       
   158                               ('ecsvexport', csvexport.CSVEntityView),
       
   159                               ('editable-table', tableview.EditableTableView),
       
   160                               ('filetree', treeview.FileTreeView),
       
   161                               ('list', baseviews.ListView),
       
   162                               ('oneline', baseviews.OneLineView),
       
   163                               ('owlabox', owl.OWLABOXView),
       
   164                               ('primary', primary.PrimaryView),
       
   165                               ('rsetxml', xmlrss.XMLRsetView),
       
   166                               ('rss', xmlrss.RSSView),
       
   167                               ('secondary', baseviews.SecondaryView),
       
   168                               ('security', management.SecurityManagementView),
       
   169                               ('table', tableview.TableView),
       
   170                               ('text', baseviews.TextView),
       
   171                               ('treeview', treeview.TreeView),
       
   172                               ('xbel', xbel.XbelView),
       
   173                               ('xml', xmlrss.XMLView),
       
   174                               ])
       
   175 
       
   176     def test_possible_views_any_rset(self):
   178     def test_possible_views_any_rset(self):
   177         rset, req = self.env.get_rset_and_req('Any N, X WHERE X in_group Y, Y name N')
   179         rset, req = self.env.get_rset_and_req('Any N, X WHERE X in_group Y, Y name N')
   178         self.assertListEqual(self.pviews(req, rset),
   180         self.assertListEqual(self.pviews(req, rset),
   179                              [('csvexport', csvexport.CSVRsetView),
   181                              [('csvexport', csvexport.CSVRsetView),
   180                               ('editable-table', tableview.EditableTableView),
   182                               ('editable-table', tableview.EditableTableView),
   183                               ])
   185                               ])
   184 
   186 
   185     def test_possible_views_multiple_eusers(self):
   187     def test_possible_views_multiple_eusers(self):
   186         rset, req = self.env.get_rset_and_req('CWUser X')
   188         rset, req = self.env.get_rset_and_req('CWUser X')
   187         self.assertListEqual(self.pviews(req, rset),
   189         self.assertListEqual(self.pviews(req, rset),
   188                              [('csvexport', csvexport.CSVRsetView),
   190                              [('adaptedlist', baseviews.AdaptedListView),
       
   191                               ('csvexport', csvexport.CSVRsetView),
   189                               ('ecsvexport', csvexport.CSVEntityView),
   192                               ('ecsvexport', csvexport.CSVEntityView),
   190                               ('editable-table', tableview.EditableTableView),
   193                               ('editable-table', tableview.EditableTableView),
   191                               ('filetree', treeview.FileTreeView),
   194                               ('filetree', treeview.FileTreeView),
   192                               ('foaf', cwuser.FoafView),
   195                               ('foaf', cwuser.FoafView),
   193                               ('list', baseviews.ListView),
   196                               ('list', baseviews.ListView),