# Path: enerdata/contracts/tariff.py
# class T20A(TariffPreTD):
#     def __init__(self):
#         super(T20A, self).__init__()
#         self.code = '2.0A'
#         self.cof = 'A'
#         self.periods = (
#             TariffPeriod('P1', 'te'),
#             TariffPeriod('P1', 'tp')
#         )
#         self.min_power = 0
#         self.max_power = 10
#         self.type = 'BT'
# 
#     def correct_powers(self, powers):
#         try:
#             if self.evaluate_powers(powers):
#                 return powers
#         except:
#             pass
# 
#         norm_power = NormalizedPower().get_norm_powers(
#             int(self.min_power * 1000), int(self.max_power * 1000)
#         ).next()
# 
#         return [norm_power / 1000.0] * len(self.power_periods)


from enerdata.profiles.profile import *
from enerdata.datetime.station import *
from enerdata.contracts.tariff import T20A
    from datetime import datetime
    from dateutil.relativedelta import relativedelta
            assert self.expected_hours == len(estimation.measures)
            assert start == estimation.start_date
            assert end == estimation.end_date

    with context("with first day of month included"):
        with it("must return until the last hour of first day of the month"):
            start = TIMEZONE.localize(datetime(2018, 1, 1, 1))
            end = TIMEZONE.localize(datetime(2018, 2, 1, 1))
            tariff = T20A()
            accumulated = 0
            balance = {
                'P1': 6.8,
                'P2': 3,
                'P3': 3.5,
            }

            profile = Profile(start, end, self.measures, accumulated)
            estimation = profile.estimate(tariff, balance)

            assert self.expected_hours + 1 == len(estimation.measures)
            assert start == estimation.start_date
            assert end == estimation.end_date

    with context("with current date to download REE coefficients last month"):
        with it("must throw the exception of: Profiles from REE not found"):
            end_year = datetime.now().year
            end_month = datetime.now().month
            start = TIMEZONE.localize(datetime(2018, 5, 1, 1))
            end = TIMEZONE.localize(datetime(end_year, end_month, 1, 0))


# Path: enerdata/contracts/tariff.py
# class T20A(TariffPreTD):
#     def __init__(self):
#         super(T20A, self).__init__()
#         self.code = '2.0A'
#         self.cof = 'A'
#         self.periods = (
#             TariffPeriod('P1', 'te'),
#             TariffPeriod('P1', 'tp')
#         )
#         self.min_power = 0
#         self.max_power = 10
#         self.type = 'BT'
# 
#     def correct_powers(self, powers):
#         try:
#             if self.evaluate_powers(powers):
#                 return powers
#         except:
#             pass
# 
#         norm_power = NormalizedPower().get_norm_powers(
#             int(self.min_power * 1000), int(self.max_power * 1000)
#         ).next()
# 
#         return [norm_power / 1000.0] * len(self.power_periods)


# Path: spec/coefficients/coefficients_spec.py
from enerdata.profiles.profile import *
from enerdata.datetime.station import *
from enerdata.contracts.tariff import T20A
    from datetime import datetime
    from dateutil.relativedelta import relativedelta

            assert self.expected_hours == len(estimation.measures)
            assert start == estimation.start_date
            assert end == estimation.end_date

    with context("with first day of month included"):
        with it("must return until the last hour of first day of the month"):
            start = TIMEZONE.localize(datetime(2018, 1, 1, 1))
            end = TIMEZONE.localize(datetime(2018, 2, 1, 1))
            tariff = T20A()
            accumulated = 0
            balance = {
                'P1': 6.8,
                'P2': 3,
                'P3': 3.5,
            }

            profile = Profile(start, end, self.measures, accumulated)
            estimation = profile.estimate(tariff, balance)

            assert self.expected_hours + 1 == len(estimation.measures)
            assert start == estimation.start_date
            assert end == estimation.end_date

    with context("with current date to download REE coefficients last month"):
        with it("must throw the exception of: Profiles from REE not found"):
            end_year = datetime.now().year
            end_month = datetime.now().month
            start = TIMEZONE.localize(datetime(2018, 5, 1, 1))
            end = TIMEZONE.localize(datetime(end_year, end_month, 1, 0))


            tariff = T20A()