<commit_before>from datetime import datetime
from enerdata.datetime.solar_hour import convert_to_solar_hour
from dateutil.relativedelta import relativedelta

with description("The civil hour"):
    with it("it's two hours more than solar"):
        dt = datetime.now()
        final_dt = dt + relativedelta(years=25)
        while dt < final_dt:
            dt = dt + relativedelta(days=1)
            res = convert_to_solar_hour(dt)
            assert dt != res
<commit_msg>Update test<commit_after>from enerdata.datetime import datetime
from enerdata.datetime.station import get_station
from enerdata.datetime.solar_hour import convert_to_solar_hour
from enerdata.datetime.timezone import TIMEZONE
from dateutil.relativedelta import relativedelta
from expects import expect, equal

DIFFERENCE_HOURS = {'summer': 2, 'winter': 1}

with description("The solar hour"):

    with context("in Summer"):
        with it("is the civil time plus 2"):
            dt = TIMEZONE.localize(datetime(2019, 4, 1, 1))
            final_dt = dt + relativedelta(months=3)
            hours = DIFFERENCE_HOURS['summer']
            while dt < final_dt:
                dt = dt + relativedelta(hours=1)
                solar_hour = convert_to_solar_hour(dt)
                civil_hour_to_expect = dt - relativedelta(hours=hours)
                assert civil_hour_to_expect.hour == solar_hour.hour
        with it("is the civil time plus 1"):
            dt = TIMEZONE.localize(datetime(2019, 11, 1, 1))
            final_dt = dt + relativedelta(months=3)
            hours = DIFFERENCE_HOURS['winter']
            while dt < final_dt:
                dt = dt + relativedelta(hours=1)
                solar_hour = convert_to_solar_hour(dt)
                civil_hour_to_expect = dt - relativedelta(hours=hours)
                assert civil_hour_to_expect.hour == solar_hour.hour

    with context("when it's random"):
        with it("must meet the difference of hours with the civil"):
            dtc = TIMEZONE.localize(datetime.now())
            station = get_station(dtc)
            hours = DIFFERENCE_HOURS[station]
            solar_hour = convert_to_solar_hour(dtc)
            civil_hour_to_expect = dtc - relativedelta(hours=hours)
            expect(civil_hour_to_expect.hour).to(equal(solar_hour.hour))
{'fraction_non_alphanumeric': 0.08576404005224206, 'fraction_numerical': 0.011319111885067479, 'mean_word_length': 2.6768, 'pattern_counts': {'":': 0, '<': 6, '<?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': '3930299', 'n_tokens_mistral': 724, 'n_tokens_neox': 686, 'n_words': 165}