Repository :
http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
---------------------------------------------------------------
commit 1192e3aab122029c21d54da01cba98560209e005
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat Nov 17 16:58:17 2012 +0100
Move the FakeUser to the top level of the tests as we need it in more place than just
test_fedocallib
---------------------------------------------------------------
fedocal/tests/__init__.py | 34 ++++++++++++++++++++++++++++++++++
fedocal/tests/test_fedocallib.py | 15 +--------------
2 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/fedocal/tests/__init__.py b/fedocal/tests/__init__.py
index 75d3197..a95652a 100644
--- a/fedocal/tests/__init__.py
+++ b/fedocal/tests/__init__.py
@@ -70,6 +70,40 @@ class Modeltests(unittest.TestCase):
os.unlink(DB_PATH)
+class FakeGroup(object):
+ """ Fake object used to make the FakeUser object closer to the
+ expectations.
+ """
+
+ def __init__(self, name):
+ """ Constructor.
+ :arg name: the name given to the name attribute of this object.
+ """
+ self.name = name
+ self.group_type = 'cla'
+
+
+# pylint: disable=R0903
+class FakeUser(object):
+ """ Fake user used to test the fedocallib library. """
+
+ def __init__(self, groups, username='username'):
+ """ Constructor.
+ :arg groups: list of the groups in which this fake user is
+ supposed to be.
+ """
+ self.groups = groups
+ self.username = username
+ self.name = username
+ self.approved_memberships = [FakeGroup('packager'),
+ FakeGroup('cla_done')]
+ self.dic = {}
+ self.dic['timezone'] = 'Europe/Paris'
+
+ def __getitem__(self, key):
+ return self.dic[key]
+
+
if __name__ == '__main__':
SUITE = unittest.TestLoader().loadTestsFromTestCase(Modeltests)
unittest.TextTestRunner(verbosity=2).run(SUITE)
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index d372b1e..0227e45 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -47,7 +47,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(
import fedocallib
from fedocallib import model
from fedocallib.exceptions import UserNotAllowed, InvalidMeeting
-from tests import Modeltests, TODAY
+from tests import Modeltests, TODAY, FakeUser
RESULT_CALENDAR_HTML = '<table class="month">\n'\
'<tr><th colspan="7" class="month"> November 2012
</th></tr>\n'\
@@ -69,19 +69,6 @@ RESULT_CALENDAR_HTML = '<table
class="month">\n'\
'</table>'
-# pylint: disable=R0903
-class FakeUser(object):
- """ Fake user used to test the fedocallib library. """
-
- def __init__(self, groups):
- """ Constructor.
- :arg groups: list of the groups in which this fake user is
- supposed to be.
- """
- self.groups = groups
- self.username = 'username'
-
-
# pylint: disable=R0904
class Fedocallibtests(Modeltests):
""" Fedocallib tests. """