# Path: radioco/apps/radioco/test_utils.py
# class TestDataMixin(object):
#     @classmethod
#     def setUpTestData(cls):
#         create_test_data()
#         cls.programme = Programme.objects.filter(name="Classic hits").get()
#         cls.schedule = cls.programme.schedule_set.first()
#         cls.calendar = cls.schedule.calendar
#         cls.episode = cls.programme.episode_set.first()
#         cls.another_calendar = Calendar.objects.create(name="Another")
# 
#         schedule, created = Schedule.objects.get_or_create(
#             programme=cls.programme,
#             calendar=cls.another_calendar,
#             type='S',
#             start_dt=pytz.utc.localize(datetime.datetime(2015, 1, 6, 16, 30, 0)))
# 
# SPAIN_TZ = pytz.timezone('Europe/Madrid')


import datetime
import pytz
from django.core.urlresolvers import reverse
from django.test import TestCase
from radioco.apps.radioco.utils import create_example_data
from radioco.apps.radioco.test_utils import TestDataMixin, SPAIN_TZ
# (at your option) any later version.
#
# This program 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 General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.




class UtilsTest(TestCase):

    def test_example_data(self):
        """
        Running example data function, If nothing crash we are happy
        """
        create_example_data()

    def test_dictionary_key(self):
        """
        Making sure that is safe to use a dt tz aware object in a different timezone to access a dictionary
        """
        utc_dt = pytz.utc.localize(datetime.datetime(2015, 1, 1, 13, 0, 0))
        spanish_dt = SPAIN_TZ.localize(datetime.datetime(2015, 1, 1, 13, 0, 0))

        utc_dict = {utc_dt: 'Created using utc dt'}
        spain_dict = {spanish_dt: 'Created using spanish dt'}

# Path: radioco/apps/radioco/test_utils.py
# class TestDataMixin(object):
#     @classmethod
#     def setUpTestData(cls):
#         create_test_data()
#         cls.programme = Programme.objects.filter(name="Classic hits").get()
#         cls.schedule = cls.programme.schedule_set.first()
#         cls.calendar = cls.schedule.calendar
#         cls.episode = cls.programme.episode_set.first()
#         cls.another_calendar = Calendar.objects.create(name="Another")
# 
#         schedule, created = Schedule.objects.get_or_create(
#             programme=cls.programme,
#             calendar=cls.another_calendar,
#             type='S',
#             start_dt=pytz.utc.localize(datetime.datetime(2015, 1, 6, 16, 30, 0)))
# 
# SPAIN_TZ = pytz.timezone('Europe/Madrid')


# Path: radioco/apps/radioco/tests/tests.py
import datetime
import pytz
from django.core.urlresolvers import reverse
from django.test import TestCase
from radioco.apps.radioco.utils import create_example_data
from radioco.apps.radioco.test_utils import TestDataMixin, SPAIN_TZ

# (at your option) any later version.
#
# This program 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 General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.




class UtilsTest(TestCase):

    def test_example_data(self):
        """
        Running example data function, If nothing crash we are happy
        """
        create_example_data()

    def test_dictionary_key(self):
        """
        Making sure that is safe to use a dt tz aware object in a different timezone to access a dictionary
        """
        utc_dt = pytz.utc.localize(datetime.datetime(2015, 1, 1, 13, 0, 0))
        spanish_dt = SPAIN_TZ.localize(datetime.datetime(2015, 1, 1, 13, 0, 0))

        utc_dict = {utc_dt: 'Created using utc dt'}
        spain_dict = {spanish_dt: 'Created using spanish dt'}

        self.assertEqual(utc_dict.get(utc_dt), utc_dict.get(utc_dt.astimezone(SPAIN_TZ)))