# 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
        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))
        self.assertEqual(date.request, request)


class FakeDatetimeServiceTests(unittest.TestCase):

    def assertDatetimeEqual(self, datetime1, datetime2):
        delta = datetime2 - datetime1
        self.assertEqual(delta.days, 0)
        self.assertTrue(delta.seconds < 2)

    def test_fakedatetimeservice(self):
        ds = FakeDatetimeService(None)
        os.environ['YITH_FAKE_DATETIME'] = '2012-1-10-14-23-01'
        fake_utcnow = datetime.datetime(2012, 1, 10, 14, 23, 1, 0)
        self.assertTrue(isinstance(ds.utcnow(), datetime.datetime))
        self.assertDatetimeEqual(ds.utcnow(), fake_utcnow)
        del os.environ['YITH_FAKE_DATETIME']

    def test_get_fakedatetime(self):
        request = object()

# 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

        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))
        self.assertEqual(date.request, request)


class FakeDatetimeServiceTests(unittest.TestCase):

    def assertDatetimeEqual(self, datetime1, datetime2):
        delta = datetime2 - datetime1
        self.assertEqual(delta.days, 0)
        self.assertTrue(delta.seconds < 2)

    def test_fakedatetimeservice(self):
        ds = FakeDatetimeService(None)
        os.environ['YITH_FAKE_DATETIME'] = '2012-1-10-14-23-01'
        fake_utcnow = datetime.datetime(2012, 1, 10, 14, 23, 1, 0)
        self.assertTrue(isinstance(ds.utcnow(), datetime.datetime))
        self.assertDatetimeEqual(ds.utcnow(), fake_utcnow)
        del os.environ['YITH_FAKE_DATETIME']

    def test_get_fakedatetime(self):
        request = object()

        datetime = get_fake_datetime(request)