Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 39aebfd8a11a8c26f10470cf0dab481bb784ba81
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Mon Nov 5 18:47:10 2012 +0100
Fix the fedocallib tests
There was a difference in the dates when the tests were ran at the
end or at the beginning of the week. So now we enforece everywhere
that the tests are ran on a Wednesday, that should avoid us having
to deal with corner cases of meetings from the past being suddenly
in the future or vice-versa
>---------------------------------------------------------------
fedocal/tests/test_fedocallib.py | 44 +++++++++++++++++--------------------
1 files changed, 20 insertions(+), 24 deletions(-)
diff --git a/fedocal/tests/test_fedocallib.py b/fedocal/tests/test_fedocallib.py
index f55e115..b813371 100644
--- a/fedocal/tests/test_fedocallib.py
+++ b/fedocal/tests/test_fedocallib.py
@@ -46,7 +46,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(
import fedocallib
from fedocallib import model
-from tests import Modeltests
+from tests import Modeltests, TODAY
RESULT_201211_HTML = """
<table class="month">
@@ -59,8 +59,6 @@ RESULT_201211_HTML = """
<tr><td class="mon">26</td><td class="tue">27</td><td class="wed">28</td><td class="thu">29</td><td class="fri">30</td><td class="noday"> </td><td class="noday"> </td></tr>
</table>
"""
-TODAY = fedocallib.get_start_week(date.today().year, date.today().month,
- date.today().day) + timedelta(days=2)
class FakeUser(object):
@@ -92,13 +90,6 @@ class Fedocallibtests(Modeltests):
meeting.session = self.session
meeting.test_init_meeting()
- def __setup_meeting_today(self):
- """ Set up basic calendar information and add some meetings in
- them (at the date of today). """
- import test_meeting
- test_meeting.TODAY = date.today()
- self.__setup_meeting()
-
def test_create_session(self):
""" Test the create_session function. """
session = fedocallib.create_session('sqlite:///:memory:')
@@ -282,11 +273,10 @@ class Fedocallibtests(Modeltests):
def test_get_past_meeting_of_user(self):
""" Test the get_past_meeting_of_user function. """
- self.__setup_meeting_today()
+ self.__setup_meeting()
meetings = fedocallib.get_past_meeting_of_user(self.session,
- 'pingou')
+ 'pingou', TODAY)
self.assertNotEqual(meetings, None)
- # The output is either 2 or 0 depending on the day the test runs
self.assertEqual(len(meetings), 0)
self.assertEqual(meetings, [])
@@ -298,7 +288,7 @@ class Fedocallibtests(Modeltests):
obj.save(self.session)
self.session.commit()
meetings = fedocallib.get_past_meeting_of_user(self.session,
- 'pingou')
+ 'pingou', TODAY)
self.assertNotEqual(meetings, None)
self.assertEqual(len(meetings), 1)
self.assertEqual(meetings[0].meeting_name, 'A past test meeting')
@@ -309,15 +299,19 @@ class Fedocallibtests(Modeltests):
""" Test the get_future_single_meeting_of_user function. """
self.__setup_meeting()
meetings = fedocallib.get_future_single_meeting_of_user(self.session,
- 'pingou')
+ 'pingou', TODAY)
self.assertNotEqual(meetings, None)
- self.assertEqual(len(meetings), 2)
- self.assertEqual(meetings[0].meeting_name, 'test-meeting2')
+ self.assertEqual(len(meetings), 3)
+ self.assertEqual(meetings[0].meeting_name,
+ 'Fedora-fr-test-meeting')
self.assertEqual(meetings[0].meeting_information,
+ 'This is a test meeting')
+ self.assertEqual(meetings[1].meeting_name, 'test-meeting2')
+ self.assertEqual(meetings[1].meeting_information,
'This is another test meeting')
- self.assertEqual(meetings[1].meeting_name,
+ self.assertEqual(meetings[2].meeting_name,
'Test meeting with reminder')
- self.assertEqual(meetings[1].meeting_information,
+ self.assertEqual(meetings[2].meeting_information,
'This is a test meeting with reminder')
def test_get_future_single_meeting_of_user_empty(self):
@@ -334,7 +328,7 @@ class Fedocallibtests(Modeltests):
""" Test the get_future_regular_meeting_of_user function. """
self.__setup_meeting()
meetings = fedocallib.get_future_regular_meeting_of_user(
- self.session, 'pingou')
+ self.session, 'pingou', TODAY)
self.assertNotEqual(meetings, None)
self.assertEqual(len(meetings), 3)
self.assertEqual(meetings[0].meeting_name,
@@ -476,16 +470,18 @@ class Fedocallibtests(Modeltests):
calendar = vobject.iCalendar()
self.__setup_meeting()
meetings = fedocallib.get_future_single_meeting_of_user(
- self.session, 'pingou')
+ self.session, 'pingou', TODAY)
self.assertNotEqual(meetings, None)
- self.assertEqual(len(meetings), 2)
+ self.assertEqual(len(meetings), 3)
fedocallib.add_meetings_to_vcal(calendar, meetings)
cnt = 0
for event in calendar.vevent_list:
self.assertTrue(event.summary.value in [
- 'Test meeting with reminder', 'test-meeting2'])
- self.assertEqual(event.organizer.value, 'pingou')
+ 'Fedora-fr-test-meeting', 'Test meeting with reminder',
+ 'test-meeting2'])
+ self.assertTrue(event.organizer.value in [
+ 'pingou', 'pingou, shaiton'])
cnt = cnt + 1
self.assertEqual(cnt, len(meetings))
Repository : http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
>---------------------------------------------------------------
commit 7da8f3b93b57134d77e5a3f84fa1ed084a3b9bed
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Mon Nov 5 18:43:53 2012 +0100
Add a from_date to the get_future* and get_past* functions
This allows to provide a starting point from which the future/past
meetings should be retrieved.
Used in the unit-tests among others to prevent problem between
start/end of the week
>---------------------------------------------------------------
fedocal/fedocallib/__init__.py | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/fedocal/fedocallib/__init__.py b/fedocal/fedocallib/__init__.py
index 351edf0..841e6b8 100644
--- a/fedocal/fedocallib/__init__.py
+++ b/fedocal/fedocallib/__init__.py
@@ -268,41 +268,49 @@ def is_date_in_future(indate, start_time):
return True
-def get_past_meeting_of_user(session, username):
+def get_past_meeting_of_user(session, username, from_date=date.today()):
""" Return all past meeting which specified username is among the
managers.
:arg session: the database session to use
:arg username: the FAS user name that you would like to have the
past meetings for.
+ :arg from_date: the date from which the futur meetings should be
+ retrieved. Defaults to today
"""
meetings = Meeting.get_past_meeting_of_user(session, username,
- date.today())
+ from_date)
return meetings
-def get_future_single_meeting_of_user(session, username):
+def get_future_single_meeting_of_user(session, username,
+ from_date=date.today()):
""" Return all future meeting which specified username is among the
managers.
:arg session: the database session to use
:arg username: the FAS user name that you would like to have the
past meetings for.
+ :arg from_date: the date from which the futur meetings should be
+ retrieved. Defaults to today
"""
meetings = Meeting.get_future_single_meeting_of_user(session,
- username, date.today())
+ username, from_date)
return meetings
-def get_future_regular_meeting_of_user(session, username):
+def get_future_regular_meeting_of_user(session, username,
+ from_date=date.today()):
""" Return all future recursive meeting which specified username is
among the managers.
:arg session: the database session to use
:arg username: the FAS user name that you would like to have the
past meetings for.
+ :arg from_date: the date from which the futur meetings should be
+ retrieved. Defaults to today
"""
meetings = Meeting.get_future_regular_meeting_of_user(session,
- username, date.today())
+ username, from_date)
return meetings