コード例 #1
0
 def test_holidays_use_backup_data(self, mock_logger):
     with responses.RequestsMock() as rsps:
         rsps.add(rsps.GET, BankHolidays.source_url, status=404)
         bank_holidays = BankHolidays()
     mock_logger.warning.assert_called_once_with(
         'Using backup bank holiday data')
     self.assertTrue(bank_holidays.get_holidays())
コード例 #2
0
def bankhols(date):
    bankhols = BankHolidays()
    print("printed")
    for bank_holiday in bankhols.get_holidays():
        if bank_holiday['date'] == date:
            print("Dupa bo: " + str(bank_holiday['date']) + " - " + str(bank_holiday['title']))
            return False
    else:
        return True
コード例 #3
0
ファイル: old_code3.py プロジェクト: gregorybutterfly/scripts
def bankhols(date):

    dat = datetime.strptime(date, "%d-%m-%Y")
    christmas = datetime(today.year, 12, 23)

    bankhols = BankHolidays()
    print("printed")



    for bank_holiday in bankhols.get_holidays():
        if bank_holiday['date'] == date:
            print("Dupa bo: " + str(bank_holiday['date']) + " - " + str(bank_holiday['title']))
            return False
    else:
        return True
コード例 #4
0
ファイル: old_code3.py プロジェクト: gregorybutterfly/scripts
 def forbiddenDates(self):

        bankhols = BankHolidays()
        christmas = datetime(today.year, 12, 23)

        while True:
            if self.date >= christmas and self.date < datetime(today.year + 1, 1, 2):
                self.date = self.date + timedelta(days=+1)
                print("Wrong date", self.date)
            elif self.date.isoweekday() == 6 or self.date.isoweekday() == 7:
                self.date = self.date + timedelta(days=+1)
            else:
                for bank_holiday in bankhols.get_holidays():
                    if bank_holiday['date'].strftime("%d-%m-%Y") == self.date.strftime("%d-%m-%Y"):
                        print("Wrong date because: " + str(bank_holiday['date']) + " - " + str(bank_holiday['title']))
                        return False
                else:
                    return self.date
コード例 #5
0
def get_bank_holidays():

    # TODO sloooooow
    bank_holiday_dates = []
    bank_holidays = BankHolidays()

    # Hacky mess to convert dates to datetimes, localised to utc
    for bank_holiday in bank_holidays.get_holidays():
        # print(bank_holiday['title'], '>', bank_holiday['date'])
        bank_holiday_dates.append(
            pytz.utc.localize(
                datetime(bank_holiday['date'].year,
                         bank_holiday['date'].month,
                         bank_holiday['date'].day)
            )
        )

    return bank_holiday_dates
コード例 #6
0
 def test_using_cached_list_of_holidays(self, mock_logger):
     with responses.RequestsMock():
         bank_holidays = BankHolidays(use_cached_holidays=True)
     mock_logger.warning.assert_not_called()
     self.assertTrue(bank_holidays.get_holidays())