Permalink
Browse files

disable accesscontrol in lowlevel unittests

  • Loading branch information...
1 parent 0782986 commit 33e61b22d1046617168db2dafa76e83cd506110b @gyst gyst committed May 21, 2012
@@ -5,10 +5,19 @@
from plonesocial.microblog.interfaces import IStatusContainer
from plonesocial.microblog.interfaces import IStatusUpdate
-from plonesocial.microblog.statuscontainer import BaseStatusContainer
+from plonesocial.microblog import statuscontainer
from plonesocial.microblog import statusupdate
+class StatusContainer(statuscontainer.BaseStatusContainer):
+ """Override actual implementation with unittest features"""
+
+ implements(IStatusContainer)
+
+ def _check_permission(self, perm="read"):
+ pass
+
+
class StatusUpdate(statusupdate.StatusUpdate):
"""Override actual implementation with unittest features"""
@@ -29,17 +38,17 @@ def _init_creator(self):
pass
-class TestBaseStatusContainer(unittest.TestCase):
+class TestStatusContainer(unittest.TestCase):
def test_verify_interface(self):
- self.assertTrue(verifyClass(IStatusContainer, BaseStatusContainer))
+ self.assertTrue(verifyClass(IStatusContainer, StatusContainer))
def test_empty(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
self.assertEqual(0, len(list(container.items())))
def test_check_status(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
class Dummy():
pass
@@ -49,21 +58,21 @@ class Dummy():
self.assertEqual(0, len(list(container.items())))
def test_add_items(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
su = StatusUpdate('test')
container.add(su)
self.assertEqual(1, len(list(container.items())))
def test_key_corresponds_to_id(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
su = StatusUpdate('test')
container.add(su)
(key, value) = list(container.items())[0]
self.assertEqual(key, value.id)
self.assertEqual(su, value)
def test_clear_items(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
su = StatusUpdate('test')
container.add(su)
self.assertEqual(1, len(list(container.items())))
@@ -73,13 +82,13 @@ def test_clear_items(self):
## primary accessors
def test_get(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
su = StatusUpdate('test')
container.add(su)
self.assertEqual(su, container.get(su.id))
def test_items_min_max(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a')
container.add(sa)
ta = sa.id # reset by container
@@ -106,7 +115,7 @@ def test_items_min_max(self):
self.assertEqual([sc], values)
def test_items_min_max_limit(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a')
container.add(sa)
ta = sa.id # reset by container
@@ -134,7 +143,7 @@ def test_items_min_max_limit(self):
self.assertEqual([sc, sb], values)
def test_iteritems_min_max(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a')
container.add(sa)
ta = sa.id # reset by container
@@ -161,7 +170,7 @@ def test_iteritems_min_max(self):
self.assertEqual([sc], values)
def test_iterkeys_min_max(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a')
container.add(sa)
ta = sa.id # reset by container
@@ -188,7 +197,7 @@ def test_iterkeys_min_max(self):
self.assertEqual([sc.id], keys)
def test_itervalues_min_max(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a')
container.add(sa)
ta = sa.id # reset by container
@@ -215,7 +224,7 @@ def test_itervalues_min_max(self):
self.assertEqual([sc], values)
def test_keys_min_max(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a')
container.add(sa)
ta = sa.id # reset by container
@@ -242,7 +251,7 @@ def test_keys_min_max(self):
self.assertEqual([sc.id], keys)
def test_values_min_max(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a')
container.add(sa)
ta = sa.id # reset by container
@@ -6,14 +6,23 @@
from plonesocial.microblog.interfaces import IStatusContainer
from plonesocial.microblog.interfaces import IStatusUpdate
-from plonesocial.microblog.statuscontainer import QueuedStatusContainer
+from plonesocial.microblog import statuscontainer
from plonesocial.microblog import statusupdate
from plonesocial.microblog.statuscontainer import STATUSQUEUE
import plonesocial.microblog.statuscontainer
plonesocial.microblog.statuscontainer.MAX_QUEUE_AGE = 50
+class StatusContainer(statuscontainer.QueuedStatusContainer):
+ """Override actual implementation with unittest features"""
+
+ implements(IStatusContainer)
+
+ def _check_permission(self, perm="read"):
+ pass
+
+
class StatusUpdate(statusupdate.StatusUpdate):
"""Override actual implementation with unittest features"""
@@ -38,7 +47,7 @@ class TestQueueStatusContainer(unittest.TestCase):
def setUp(self):
# needed for thread teardown
- self.container = QueuedStatusContainer()
+ self.container = StatusContainer()
# make sure also first item will be queued
self.container._mtime = int(time.time() * 1000)
@@ -58,7 +67,7 @@ def tearDown(self):
break
def test_verify_interface(self):
- self.assertTrue(verifyClass(IStatusContainer, QueuedStatusContainer))
+ self.assertTrue(verifyClass(IStatusContainer, StatusContainer))
def test_add_queued(self):
"""Test the queueing"""
@@ -2,11 +2,21 @@
import unittest2 as unittest
from zope.interface import implements
+from plonesocial.microblog.interfaces import IStatusContainer
from plonesocial.microblog.interfaces import IStatusUpdate
-from plonesocial.microblog.statuscontainer import BaseStatusContainer
+from plonesocial.microblog import statuscontainer
from plonesocial.microblog import statusupdate
+class StatusContainer(statuscontainer.BaseStatusContainer):
+ """Override actual implementation with unittest features"""
+
+ implements(IStatusContainer)
+
+ def _check_permission(self, perm="read"):
+ pass
+
+
class StatusUpdate(statusupdate.StatusUpdate):
"""Override actual implementation with unittest features"""
@@ -32,7 +42,7 @@ class TestStatusContainer_User(unittest.TestCase):
## user accessors
def test_user_items_all(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
sb = StatusUpdate('test b', 'bernard')
@@ -44,7 +54,7 @@ def test_user_items_all(self):
self.assertEqual([sc, sb, sa], values)
def test_user_items_limit(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
sb = StatusUpdate('test b', 'bernard')
@@ -57,7 +67,7 @@ def test_user_items_limit(self):
self.assertEqual([sc, sb], values)
def test_user_items_some(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
sb = StatusUpdate('test b', 'bernard')
@@ -69,7 +79,7 @@ def test_user_items_some(self):
self.assertEqual([sb, sa], values)
def test_user_items_one(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
sb = StatusUpdate('test b', 'bernard')
@@ -81,7 +91,7 @@ def test_user_items_one(self):
self.assertEqual([sb], values)
def test_user_items_none(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
sb = StatusUpdate('test b', 'bernard')
@@ -93,7 +103,7 @@ def test_user_items_none(self):
self.assertEqual([], values)
def test_user_items_min_max_all(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
ta = sa.id # reset by container
@@ -122,7 +132,7 @@ def test_user_items_min_max_all(self):
self.assertEqual([sc], values)
def test_user_items_min_max_some(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
ta = sa.id # reset by container
@@ -151,7 +161,7 @@ def test_user_items_min_max_some(self):
self.assertEqual([sc], values)
def test_user_keys_min_max_some(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
ta = sa.id # reset by container
@@ -180,7 +190,7 @@ def test_user_keys_min_max_some(self):
self.assertEqual([sc.id], values)
def test_user_values_min_max_some(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
ta = sa.id # reset by container
@@ -209,7 +219,7 @@ def test_user_values_min_max_some(self):
self.assertEqual([sc], values)
def test_user_keys_generator(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
ta = sa.id # reset by container
@@ -230,7 +240,7 @@ def test_user_keys_generator(self):
self.assertEqual([sb], values)
def test_user_keys_generator_empty(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
ta = sa.id # reset by container
@@ -250,7 +260,7 @@ def test_user_keys_generator_empty(self):
self.assertEqual([], values)
def test_user_keys_string(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
ta = sa.id # reset by container
@@ -273,7 +283,7 @@ def test_user_keys_string(self):
self.assertEqual([], values)
def test_user_keys_None(self):
- container = BaseStatusContainer()
+ container = StatusContainer()
sa = StatusUpdate('test a', 'arnold')
container.add(sa)
ta = sa.id # reset by container

0 comments on commit 33e61b2

Please sign in to comment.