# Path: nba_data/data/date_range.py
# class DateRange:
#     def __init__(self, start=date.today(), end=date.today()):
#         assert start <= end
# 
#         self.start = start
#         self.end = end
# 
#     def is_date_in_range(self, value):
#         assert isinstance(value, date)
# 
#         return self.start <= value <= self.end
# 
# Path: nba_data/deserializers/calendar.py
# class CalendarDeserializer:
#     internal_field_name = "_internal"
#     start_date_field_name = "startDate"
#     end_date_field_name = "endDate"
#     start_date_current_season_field_name = "startDateCurrentSeason"
#     fields_to_ignore = { internal_field_name, start_date_field_name, end_date_field_name, start_date_current_season_field_name }
#     date_format = "%Y%m%d"
# 
#     def __init__(self):
#         pass
# 
#     # TODO: @jbradley add pub date time to returned object
#     @staticmethod
#     def deserialize(calendar_json, date_range=DateRange(), ignore_dates_without_games=True):
#         calendar_values = {}
#         for key, value in calendar_json.items():
#             if ((value != 0 and ignore_dates_without_games is True) or ignore_dates_without_games is False) \
#                     and key not in CalendarDeserializer.fields_to_ignore:
#                 date_value = datetime.strptime(key, CalendarDeserializer.date_format).date()
#                 if date_range.is_date_in_range(value=date_value):
#                     calendar_values[date_value] = value
#         return calendar_values
# 
# Path: tests/config.py
# ROOT_DIRECTORY = root_path = os.path.dirname(os.path.dirname(__file__))


import json
import os
from datetime import date
from unittest import TestCase
from nba_data.data.date_range import DateRange
from nba_data.deserializers.calendar import CalendarDeserializer
from tests.config import ROOT_DIRECTORY



class TestCalendarDeserializer(TestCase):
    def test_instantiation(self):
        self.assertIsNotNone(CalendarDeserializer())

    def test_deserialize(self):
        start = date(year=2016, month=12, day=1)
        end = date(year=2017, month=2, day=15)
        date_range = DateRange(start=start, end=end)
        very_beginning = date(year=2015, month=10, day=2)
        very_end = date(year=2017, month=4, day=12)

# Path: nba_data/data/date_range.py
# class DateRange:
#     def __init__(self, start=date.today(), end=date.today()):
#         assert start <= end
# 
#         self.start = start
#         self.end = end
# 
#     def is_date_in_range(self, value):
#         assert isinstance(value, date)
# 
#         return self.start <= value <= self.end
# 
# Path: nba_data/deserializers/calendar.py
# class CalendarDeserializer:
#     internal_field_name = "_internal"
#     start_date_field_name = "startDate"
#     end_date_field_name = "endDate"
#     start_date_current_season_field_name = "startDateCurrentSeason"
#     fields_to_ignore = { internal_field_name, start_date_field_name, end_date_field_name, start_date_current_season_field_name }
#     date_format = "%Y%m%d"
# 
#     def __init__(self):
#         pass
# 
#     # TODO: @jbradley add pub date time to returned object
#     @staticmethod
#     def deserialize(calendar_json, date_range=DateRange(), ignore_dates_without_games=True):
#         calendar_values = {}
#         for key, value in calendar_json.items():
#             if ((value != 0 and ignore_dates_without_games is True) or ignore_dates_without_games is False) \
#                     and key not in CalendarDeserializer.fields_to_ignore:
#                 date_value = datetime.strptime(key, CalendarDeserializer.date_format).date()
#                 if date_range.is_date_in_range(value=date_value):
#                     calendar_values[date_value] = value
#         return calendar_values
# 
# Path: tests/config.py
# ROOT_DIRECTORY = root_path = os.path.dirname(os.path.dirname(__file__))


# Path: tests/test_calendarDeserializer.py
import json
import os
from datetime import date
from unittest import TestCase
from nba_data.data.date_range import DateRange
from nba_data.deserializers.calendar import CalendarDeserializer
from tests.config import ROOT_DIRECTORY




class TestCalendarDeserializer(TestCase):
    def test_instantiation(self):
        self.assertIsNotNone(CalendarDeserializer())

    def test_deserialize(self):
        start = date(year=2016, month=12, day=1)
        end = date(year=2017, month=2, day=15)
        date_range = DateRange(start=start, end=end)
        very_beginning = date(year=2015, month=10, day=2)
        very_end = date(year=2017, month=4, day=12)

        complete_date_range = DateRange(start=very_beginning, end=very_end)