<commit_before>import unittest
import datetime

from unittest.mock import patch

from forecast.Location import Location
from forecast.Forecast import Forecast
from forecast.Hour import Hour
from forecast.WeatherGovSource import WeatherGovSource


class ForecastTestCase(unittest.TestCase):
    """
    """


    def testIsDaylight(self):
        # bracket: before/after sunrise, eve: before/after sunset
        latLonToStartValidTimesIsDaylight = {
            # MA UTC/GMT -5 hours, EST
            ("42.38", "-72.50"): [
                ('2015-01-14T00:00:00-05:00', False),
                ('2015-01-14T01:00:00-05:00', False),
                ('2015-01-14T02:00:00-05:00', False),
                ('2015-01-14T03:00:00-05:00', False),
                ('2015-01-14T04:00:00-05:00', False),
                ('2015-01-14T05:00:00-05:00', False),
                ('2015-01-14T06:00:00-05:00', False),
                ('2015-01-14T07:00:00-05:00', True),
                ('2015-01-14T08:00:00-05:00', True),
                ('2015-01-14T09:00:00-05:00', True),
                ('2015-01-14T10:00:00-05:00', True),
                ('2015-01-14T11:00:00-05:00', True),
                ('2015-01-14T12:00:00-05:00', True),
                ('2015-01-14T13:00:00-05:00', True),
                ('2015-01-14T14:00:00-05:00', True),
                ('2015-01-14T15:00:00-05:00', True),
                ('2015-01-14T16:00:00-05:00', True),
                ('2015-01-14T17:00:00-05:00', True),
                ('2015-01-14T18:00:00-05:00', False),
                ('2015-01-14T19:00:00-05:00', False),
                ('2015-01-14T20:00:00-05:00', False),
                ('2015-01-14T21:00:00-05:00', False),
                ('2015-01-14T22:00:00-05:00', False),
                ('2015-01-14T23:00:00-05:00', False),
            ],
            # CA UTC/GMT -8 hours, PST
            ("32.74", "-117.10"): [
                ('2015-01-31T00:00:00-08:00', False),
                ('2015-01-31T01:00:00-08:00', False),
                ('2015-01-31T02:00:00-08:00', False),
                ('2015-01-31T03:00:00-08:00', False),
                ('2015-01-31T04:00:00-08:00', False),
                ('2015-01-31T05:00:00-08:00', False),
                ('2015-01-31T06:00:00-08:00', True),
                ('2015-01-31T07:00:00-08:00', True),
                ('2015-01-31T08:00:00-08:00', True),
                ('2015-01-31T09:00:00-08:00', True),
                ('2015-01-31T10:00:00-08:00', True),
                ('2015-01-31T11:00:00-08:00', True),
                ('2015-01-31T12:00:00-08:00', True),
                ('2015-01-31T13:00:00-08:00', True),
                ('2015-01-31T14:00:00-08:00', True),
                ('2015-01-31T15:00:00-08:00', True),
                ('2015-01-31T16:00:00-08:00', True),
                ('2015-01-31T17:00:00-08:00', True),
                ('2015-01-31T18:00:00-08:00', True),
                ('2015-01-31T19:00:00-08:00', False),
                ('2015-01-31T20:00:00-08:00', False),
                ('2015-01-31T21:00:00-08:00', False),
                ('2015-01-31T22:00:00-08:00', False),
                ('2015-01-31T23:00:00-08:00', False),
            ],
            # HI UTC/GMT -10 hours, HAST
            ("20.09", "-155.52"): [
                ('2015-02-02T00:00:00-10:00', False),
                ('2015-02-02T01:00:00-10:00', False),
                ('2015-02-02T02:00:00-10:00', False),
                ('2015-02-02T03:00:00-10:00', False),
                ('2015-02-02T04:00:00-10:00', False),
                ('2015-02-02T05:00:00-10:00', False),
                ('2015-02-02T06:00:00-10:00', False),
                ('2015-02-02T07:00:00-10:00', True),
                ('2015-02-02T08:00:00-10:00', True),
                ('2015-02-02T09:00:00-10:00', True),
                ('2015-02-02T10:00:00-10:00', True),
                ('2015-02-02T11:00:00-10:00', True),
                ('2015-02-02T12:00:00-10:00', True),
                ('2015-02-02T13:00:00-10:00', True),
                ('2015-02-02T14:00:00-10:00', True),
                ('2015-02-02T15:00:00-10:00', True),
                ('2015-02-02T16:00:00-10:00', True),
                ('2015-02-02T17:00:00-10:00', True),
                ('2015-02-02T18:00:00-10:00', True),
                ('2015-02-02T19:00:00-10:00', True),
                ('2015-02-02T20:00:00-10:00', False),
                ('2015-02-02T21:00:00-10:00', False),
                ('2015-02-02T22:00:00-10:00', False),
                ('2015-02-02T23:00:00-10:00', False),
            ],
        }
        for latLon, startValidTimesIsDaylight in latLonToStartValidTimesIsDaylight.items():
            for startValidTimeText, expIsDaylight in startValidTimesIsDaylight:
                dt = WeatherGovSource.parseStartValidTime(startValidTimeText)
                isDaylight = Hour.isDaylightDatetime(Location(latLon), dt)
                self.assertEqual(expIsDaylight, isDaylight)

        with self.assertRaisesRegex(ValueError, "datetime has no tzinfo"):
            Hour.isDaylightDatetime(None, datetime.datetime.now())


    def testCharIconsForParams_TODO(self):
        # mockHour = Mock()   # todo paramDesirabilityForValue()
        self.fail()


    @patch('forecast.Forecast.WeatherGovSource')
    def testParamDesirabilityForValue(self, MockWeatherGovSource):
        # check individual parameter ratings
        expParamValRatings = {
            'precip': [(0, Hour.P_DES_HIGH),
                       (9, Hour.P_DES_HIGH),<commit_msg>missed a file<commit_after>import unittest
import datetime

from unittest.mock import patch

from forecast.Location import Location
from forecast.Forecast import Forecast
from forecast.Hour import Hour
from forecast.WeatherGovSource import WeatherGovSource


class ForecastTestCase(unittest.TestCase):
    """
    """


    def testIsDaylight(self):
        # bracket: before/after sunrise, eve: before/after sunset
        latLonToStartValidTimesIsDaylight = {
            # MA UTC/GMT -5 hours, EST
            ("42.38", "-72.50"): [
                ('2015-01-14T00:00:00-05:00', False),
                ('2015-01-14T01:00:00-05:00', False),
                ('2015-01-14T02:00:00-05:00', False),
                ('2015-01-14T03:00:00-05:00', False),
                ('2015-01-14T04:00:00-05:00', False),
                ('2015-01-14T05:00:00-05:00', False),
                ('2015-01-14T06:00:00-05:00', False),
                ('2015-01-14T07:00:00-05:00', True),
                ('2015-01-14T08:00:00-05:00', True),
                ('2015-01-14T09:00:00-05:00', True),
                ('2015-01-14T10:00:00-05:00', True),
                ('2015-01-14T11:00:00-05:00', True),
                ('2015-01-14T12:00:00-05:00', True),
                ('2015-01-14T13:00:00-05:00', True),
                ('2015-01-14T14:00:00-05:00', True),
                ('2015-01-14T15:00:00-05:00', True),
                ('2015-01-14T16:00:00-05:00', True),
                ('2015-01-14T17:00:00-05:00', True),
                ('2015-01-14T18:00:00-05:00', False),
                ('2015-01-14T19:00:00-05:00', False),
                ('2015-01-14T20:00:00-05:00', False),
                ('2015-01-14T21:00:00-05:00', False),
                ('2015-01-14T22:00:00-05:00', False),
                ('2015-01-14T23:00:00-05:00', False),
            ],
            # CA UTC/GMT -8 hours, PST
            ("32.74", "-117.10"): [
                ('2015-01-31T00:00:00-08:00', False),
                ('2015-01-31T01:00:00-08:00', False),
                ('2015-01-31T02:00:00-08:00', False),
                ('2015-01-31T03:00:00-08:00', False),
                ('2015-01-31T04:00:00-08:00', False),
                ('2015-01-31T05:00:00-08:00', False),
                ('2015-01-31T06:00:00-08:00', True),
                ('2015-01-31T07:00:00-08:00', True),
                ('2015-01-31T08:00:00-08:00', True),
                ('2015-01-31T09:00:00-08:00', True),
                ('2015-01-31T10:00:00-08:00', True),
                ('2015-01-31T11:00:00-08:00', True),
                ('2015-01-31T12:00:00-08:00', True),
                ('2015-01-31T13:00:00-08:00', True),
                ('2015-01-31T14:00:00-08:00', True),
                ('2015-01-31T15:00:00-08:00', True),
                ('2015-01-31T16:00:00-08:00', True),
                ('2015-01-31T17:00:00-08:00', True),
                ('2015-01-31T18:00:00-08:00', True),
                ('2015-01-31T19:00:00-08:00', False),
                ('2015-01-31T20:00:00-08:00', False),
                ('2015-01-31T21:00:00-08:00', False),
                ('2015-01-31T22:00:00-08:00', False),
                ('2015-01-31T23:00:00-08:00', False),
            ],
            # HI UTC/GMT -10 hours, HAST
            ("20.09", "-155.52"): [
                ('2015-02-02T00:00:00-10:00', False),
                ('2015-02-02T01:00:00-10:00', False),
                ('2015-02-02T02:00:00-10:00', False),
                ('2015-02-02T03:00:00-10:00', False),
                ('2015-02-02T04:00:00-10:00', False),
                ('2015-02-02T05:00:00-10:00', False),
                ('2015-02-02T06:00:00-10:00', False),
                ('2015-02-02T07:00:00-10:00', True),
                ('2015-02-02T08:00:00-10:00', True),
                ('2015-02-02T09:00:00-10:00', True),
                ('2015-02-02T10:00:00-10:00', True),
                ('2015-02-02T11:00:00-10:00', True),
                ('2015-02-02T12:00:00-10:00', True),
                ('2015-02-02T13:00:00-10:00', True),
                ('2015-02-02T14:00:00-10:00', True),
                ('2015-02-02T15:00:00-10:00', True),
                ('2015-02-02T16:00:00-10:00', True),
                ('2015-02-02T17:00:00-10:00', True),
                ('2015-02-02T18:00:00-10:00', True),
                ('2015-02-02T19:00:00-10:00', True),
                ('2015-02-02T20:00:00-10:00', False),
                ('2015-02-02T21:00:00-10:00', False),
                ('2015-02-02T22:00:00-10:00', False),
                ('2015-02-02T23:00:00-10:00', False),
            ],
        }
        for latLon, startValidTimesIsDaylight in latLonToStartValidTimesIsDaylight.items():
            for startValidTimeText, expIsDaylight in startValidTimesIsDaylight:
                dt = WeatherGovSource.parseStartValidTime(startValidTimeText)
                isDaylight = Hour.isDaylightDatetime(Location(latLon), dt)
                self.assertEqual(expIsDaylight, isDaylight)

        with self.assertRaisesRegex(ValueError, "datetime has no tzinfo"):
            Hour.isDaylightDatetime(None, datetime.datetime.now())


    # def testCharIconsForParams(self):
    #     self.fail()


    @patch('forecast.Forecast.WeatherGovSource')
    def testParamDesirabilityForValue(self, MockWeatherGovSource):
        # check individual parameter ratings
        expParamValRatings = {
            'precip': [(0, Hour.P_DES_HIGH),
                       (9, Hour.P_DES_HIGH),
{'fraction_non_alphanumeric': 0.18602326426753907, 'fraction_numerical': 0.24136677571792076, 'mean_word_length': 1.765075376884422, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6228489', 'n_tokens_mistral': 5635, 'n_tokens_neox': 3974, 'n_words': 489}