def test_given_a_business_day_and_a_period_that_includes_a_working_date_weekend( self): test_date = parse_date_noniso("Friday 4th Jan, 2013") calendar = Calendar(holidays=["Tuesday 1st Jan, 2013"], extra_working_dates=["Sunday 6th Jan, 2013"]) assert (calendar.add_business_days(test_date, self.delta) == test_date + (self.delta + 1) * day_interval)
def test_given_a_business_day_and_a_period_that_includes_a_working_date_weekend( self): test_date = parse_date_noniso("Monday 31st Dec, 2012") calendar = Calendar(holidays=["Tuesday 1st Jan, 2013"], extra_working_dates=["Saturday 29th Dec, 2012"]) assert (calendar.add_business_days(test_date, -self.delta) == test_date - (self.delta + 1) * day_interval)
def test_given_a_non_business_day_preceded_by_another_non_business_day( self): test_date = parse_date_noniso("Sunday 6th Jan, 2013") assert self.calendar.roll_backward( test_date) == test_date - (2 * day_interval)
def test_given_a_non_business_day_with_a_business_day_preceding_it(self): test_date = parse_date_noniso("Tuesday 1st Jan, 2013") assert self.calendar.roll_backward( test_date) == test_date - day_interval
def test_given_a_business_day(self): test_date = parse_date_noniso("Wednesday 2nd Jan, 2013") assert self.calendar.roll_backward(test_date) == test_date
def test_when_given_a_business_day(self): test_date = parse_date_noniso("9am, Wednesday 2nd Jan, 2013") assert self.calendar.is_business_day(test_date) is True
def test_given_a_non_business_day(self): test_date = parse_date_noniso("Thursday 3rd Jan, 2013") assert (self.calendar.add_business_days(test_date, -self.delta) == test_date - (self.delta + 1) * day_interval)
import pytest from business.calendar import Calendar from conftest import parse_date_noniso scenarios_list = [ { "context": "month starts on a business day", "scenarios": [ { "context": "including first day", "input_date": parse_date_noniso("Tue 1/7/2014"), "expected": 1, }, { "context": "including holidays & weekend days", "input_date": parse_date_noniso("Sun 6/7/2014"), "expected": 3, }, { "context": "including last day", "input_date": parse_date_noniso("Thu 31/7/2014"), "expected": 22, }, ], }, { "context": "month starts on a holiday", "scenarios": [
def test_given_a_non_business_day_with_a_business_day_following_it(self): test_date = parse_date_noniso("Tuesday 1st Jan, 2013") assert self.calendar.next_business_day( test_date) == test_date + day_interval
import pytest from business.calendar import Calendar from conftest import parse_date_noniso scenarios_list = [ { "context": "starting on a business day", "date_1": parse_date_noniso("Mon 2/6/2014"), "scenarios": [ { "context": "ending on a business day", "scenarios": [ { "context": "including only business days", "date_2": parse_date_noniso("Thu 5/6/2014"), "expected": 3, }, { "context": "including only business days & weekend days", "date_2": parse_date_noniso("Mon 9/6/2014"), "expected": 5, }, { "context": "including only business days, weekend days & working date", "date_1": parse_date_noniso("Thu 29/5/2014"),
def test_that_also_exists_as_a_default_calendar(self): calendar = Calendar.load("bacs") assert calendar.is_business_day( parse_date_noniso("25th December 2014"))
def test_when_given_a_non_business_day_that_is_a_working_date(self): test_date = parse_date_noniso("9am, Sunday 6th Jan, 2013") assert self.calendar.is_business_day(test_date) is True
def test_when_given_a_business_day_that_is_a_holiday(self): test_date = parse_date_noniso("9am, Tuesday 1st Jan, 2013") assert self.calendar.is_business_day(test_date) is False
def test_when_given_a_non_business_day(self): test_date = parse_date_noniso("9am, Saturday 5th Jan, 2013") assert self.calendar.is_business_day(test_date) is False
def test_given_a_business_day_and_a_period_that_includes_only_business_days( self): test_date = parse_date_noniso("Wednesday 2nd Jan, 2013") assert (self.calendar.add_business_days( test_date, -self.delta) == test_date - self.delta * day_interval)
def test_given_a_business_day(self): test_date = parse_date_noniso("Thursday 3nd Jan, 2013") assert self.calendar.previous_business_day( test_date) == test_date - day_interval
def test_given_a_business_day_and_a_period_that_includes_a_weekend(self): test_date = parse_date_noniso("Monday 31st Dec, 2012") assert (self.calendar.add_business_days(test_date, -self.delta) == test_date - (self.delta + 2) * day_interval)
def test_add_zero_days(self): test_date = parse_date_noniso("Wednesday 2nd Jan, 2013") result = self.calendar.add_business_days(test_date, 0) assert result == test_date
def test_given_a_business_day_and_a_period_that_includes_a_holiday_day( self): test_date = parse_date_noniso("Friday 4th Jan, 2013") assert (self.calendar.add_business_days(test_date, -self.delta) == test_date - (self.delta + 1) * day_interval)
def test_given_a_non_business_day_followed_by_another_non_business_day( self): test_date = parse_date_noniso("Saturday 5th Jan, 2013") assert self.calendar.roll_forward( test_date) == test_date + (2 * day_interval)
def test_given_a_business_day(self): test_date = parse_date_noniso("Wednesday 2nd Jan, 2013") assert self.calendar.next_business_day( test_date) == test_date + day_interval
def test_parse_date_str_noniso(): assert parse_date_noniso("6/1/2019") == datetime.date(2019, 1, 6)