# Path: yithlibraryserver/datetimeservice/testing.py
# class FakeDateService(object):
# 
#     def __init__(self, request):
#         self.request = request
# 
#     def today(self):
#         fake = os.environ['YITH_FAKE_DATE']
#         parts = [int(p) for p in fake.split('-')]
#         return datetime.date(*parts)
# 
# def get_fake_date(request):
#     return FakeDateService(request)
# 
# Path: yithlibraryserver/datetimeservice/testing.py
# class FakeDatetimeService(object):
# 
#     def __init__(self, request):
#         self.request = request
# 
#     def utcnow(self):
#         fake = os.environ['YITH_FAKE_DATETIME']
#         parts = [int(p) for p in fake.split('-')]
#         return datetime.datetime(*parts)
# 
# def get_fake_datetime(request):
#     return FakeDatetimeService(request)


import os
import datetime
import unittest
from yithlibraryserver.datetimeservice.testing import FakeDateService, get_fake_date
from yithlibraryserver.datetimeservice.testing import FakeDatetimeService, get_fake_datetime
#
# Yith Library Server is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Yith Library Server.  If not, see <http://www.gnu.org/licenses/>.





class FakeDateServiceTests(unittest.TestCase):

    def assertDateEqual(self, date1, date2):
        delta = date2 - date1
        self.assertEqual(delta.days, 0)

    def test_dateservice(self):
        ds = FakeDateService(None)
        fake_today = datetime.date(2012, 1, 10)
        os.environ['YITH_FAKE_DATE'] = '2012-1-10'
        self.assertTrue(isinstance(ds.today(), datetime.date))
        self.assertDateEqual(ds.today(), fake_today)
        del os.environ['YITH_FAKE_DATE']

    def test_get_fake_date(self):
        request = object()
        date = get_fake_date(request)

# Path: yithlibraryserver/datetimeservice/testing.py
# class FakeDateService(object):
# 
#     def __init__(self, request):
#         self.request = request
# 
#     def today(self):
#         fake = os.environ['YITH_FAKE_DATE']
#         parts = [int(p) for p in fake.split('-')]
#         return datetime.date(*parts)
# 
# def get_fake_date(request):
#     return FakeDateService(request)
# 
# Path: yithlibraryserver/datetimeservice/testing.py
# class FakeDatetimeService(object):
# 
#     def __init__(self, request):
#         self.request = request
# 
#     def utcnow(self):
#         fake = os.environ['YITH_FAKE_DATETIME']
#         parts = [int(p) for p in fake.split('-')]
#         return datetime.datetime(*parts)
# 
# def get_fake_datetime(request):
#     return FakeDatetimeService(request)


# Path: yithlibraryserver/datetimeservice/tests/test_testing.py
import os
import datetime
import unittest
from yithlibraryserver.datetimeservice.testing import FakeDateService, get_fake_date
from yithlibraryserver.datetimeservice.testing import FakeDatetimeService, get_fake_datetime

#
# Yith Library Server is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Yith Library Server.  If not, see <http://www.gnu.org/licenses/>.





class FakeDateServiceTests(unittest.TestCase):

    def assertDateEqual(self, date1, date2):
        delta = date2 - date1
        self.assertEqual(delta.days, 0)

    def test_dateservice(self):
        ds = FakeDateService(None)
        fake_today = datetime.date(2012, 1, 10)
        os.environ['YITH_FAKE_DATE'] = '2012-1-10'
        self.assertTrue(isinstance(ds.today(), datetime.date))
        self.assertDateEqual(ds.today(), fake_today)
        del os.environ['YITH_FAKE_DATE']

    def test_get_fake_date(self):
        request = object()
        date = get_fake_date(request)

        self.assertTrue(isinstance(date, FakeDateService))