本文整理汇总了Python中Products.CMFCore.tests.base.dummy.DummyContent._View_Permission方法的典型用法代码示例。如果您正苦于以下问题:Python DummyContent._View_Permission方法的具体用法?Python DummyContent._View_Permission怎么用?Python DummyContent._View_Permission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.CMFCore.tests.base.dummy.DummyContent
的用法示例。
在下文中一共展示了DummyContent._View_Permission方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_search_restrict_inactive
# 需要导入模块: from Products.CMFCore.tests.base.dummy import DummyContent [as 别名]
# 或者: from Products.CMFCore.tests.base.dummy.DummyContent import _View_Permission [as 别名]
def test_search_restrict_inactive(self):
catalog = self._makeOne()
now = DateTime()
dummy = DummyContent(catalog=1)
dummy._View_Permission = ('Blob',)
self.loginWithRoles('Blob')
# already expired
dummy.effective = now-4
dummy.expires = now-2
catalog.catalog_object(dummy, '/dummy')
self.assertEqual(1, len(catalog._catalog.searchResults()))
self.assertEqual(0, len(catalog.searchResults()))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now-3, 'range': 'min'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now-3, 'range': 'max'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now+3, 'range': 'min'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now+3, 'range': 'max'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': (now-3, now-1), 'range': 'min:max'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': (now-3, now-1), 'range': 'minmax'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now-2, 'range': None})))
示例2: test_search_member_wo_valid_roles
# 需要导入模块: from Products.CMFCore.tests.base.dummy import DummyContent [as 别名]
# 或者: from Products.CMFCore.tests.base.dummy.DummyContent import _View_Permission [as 别名]
def test_search_member_wo_valid_roles(self):
catalog = self._makeOne()
catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
dummy = DummyContent(catalog=1)
dummy._View_Permission = ('Blob',)
catalog.catalog_object(dummy, '/dummy')
self.loginWithRoles('Waggle')
self.assertEqual(1, len(catalog._catalog.searchResults()))
self.assertEqual(0, len(catalog.searchResults()))
示例3: test_search_inactive
# 需要导入模块: from Products.CMFCore.tests.base.dummy import DummyContent [as 别名]
# 或者: from Products.CMFCore.tests.base.dummy.DummyContent import _View_Permission [as 别名]
def test_search_inactive(self):
catalog = self._makeOne()
now = DateTime()
dummy = DummyContent(catalog=1)
dummy._View_Permission = ('Blob',)
self.loginWithRoles('Blob')
# not yet effective
dummy.effective = now+1
dummy.expires = now+2
catalog.catalog_object(dummy, '/dummy')
self.assertEqual(1, len(catalog._catalog.searchResults()))
self.assertEqual(0, len(catalog.searchResults()))
# already expired
dummy.effective = now-2
dummy.expires = now-1
catalog.catalog_object(dummy, '/dummy')
self.assertEqual(1, len(catalog._catalog.searchResults()))
self.assertEqual(0, len(catalog.searchResults()))
示例4: test_search_restrict_visible
# 需要导入模块: from Products.CMFCore.tests.base.dummy import DummyContent [as 别名]
# 或者: from Products.CMFCore.tests.base.dummy.DummyContent import _View_Permission [as 别名]
def test_search_restrict_visible(self):
catalog = self._makeOne()
catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
catalog.addIndex('effective', 'DateIndex')
catalog.addIndex('expires', 'DateIndex')
now = DateTime()
dummy = DummyContent(catalog=1)
dummy._View_Permission = ('Blob',)
self.loginWithRoles('Blob')
# visible
dummy.effective = now-2
dummy.expires = now+2
catalog.catalog_object(dummy, '/dummy')
self.assertEqual(1, len(catalog._catalog.searchResults()))
self.assertEqual(1, len(catalog.searchResults()))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': now-1, 'range': 'min'})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': now-1, 'range': 'max'})))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': now+1, 'range': 'min'})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': now+1, 'range': 'max'})))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': (now-1, now+1), 'range': 'min:max'})))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': (now-1, now+1), 'range': 'minmax'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': now-2, 'range': None})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': now-3, 'range': 'min'})))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': now-3, 'range': 'max'})))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': now+3, 'range': 'min'})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': now+3, 'range': 'max'})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': (now-3, now+3), 'range': 'min:max'})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': (now-3, now+3), 'range': 'minmax'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': now-1, 'range': 'min'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now-1, 'range': 'max'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': now+1, 'range': 'min'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now+1, 'range': 'max'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': (now-1, now+1), 'range': 'min:max'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': (now-1, now+1), 'range': 'minmax'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': now-3, 'range': 'min'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now-3, 'range': 'max'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now+3, 'range': 'min'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': now+3, 'range': 'max'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': (now-3, now+3), 'range': 'min:max'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': (now-3, now+3), 'range': 'minmax'})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': now-1, 'range': 'max'},
expires={'query': now+1, 'range': 'min'})))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': now+1, 'range': 'max'},
expires={'query': now+3, 'range': 'min'})))
示例5: test_search_restrict_visible
# 需要导入模块: from Products.CMFCore.tests.base.dummy import DummyContent [as 别名]
# 或者: from Products.CMFCore.tests.base.dummy.DummyContent import _View_Permission [as 别名]
def test_search_restrict_visible(self):
catalog = CatalogTool()
now = DateTime()
dummy = DummyContent(catalog=1)
dummy._View_Permission = ('Blob',)
self.loginWithRoles('Blob')
# visible
dummy.effective = now-2
dummy.expires = now+2
catalog.catalog_object(dummy, '/dummy')
self.assertEqual(1, len(catalog._catalog.searchResults()))
self.assertEqual(1, len(catalog.searchResults()))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': now-1, 'range': 'min'})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': now-1, 'range': 'max'})))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': now+1, 'range': 'min'})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': now+1, 'range': 'max'})))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': (now-1, now+1), 'range': 'min:max'})))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': (now-1, now+1), 'range': 'minmax'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': now-2, 'range': None})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': now-3, 'range': 'min'})))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': now-3, 'range': 'max'})))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': now+3, 'range': 'min'})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': now+3, 'range': 'max'})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': (now-3, now+3), 'range': 'min:max'})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': (now-3, now+3), 'range': 'minmax'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': now-1, 'range': 'min'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now-1, 'range': 'max'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': now+1, 'range': 'min'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now+1, 'range': 'max'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': (now-1, now+1), 'range': 'min:max'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': (now-1, now+1), 'range': 'minmax'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': now-3, 'range': 'min'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now-3, 'range': 'max'})))
self.assertEqual(0, len(catalog.searchResults(
expires={'query': now+3, 'range': 'min'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': now+3, 'range': 'max'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': (now-3, now+3), 'range': 'min:max'})))
self.assertEqual(1, len(catalog.searchResults(
expires={'query': (now-3, now+3), 'range': 'minmax'})))
self.assertEqual(1, len(catalog.searchResults(
effective={'query': now-1, 'range': 'max'},
expires={'query': now+1, 'range': 'min'})))
self.assertEqual(0, len(catalog.searchResults(
effective={'query': now+1, 'range': 'max'},
expires={'query': now+3, 'range': 'min'})))