def test_is_not_active_first_day_after_vacation(self): rule_handler = german_vacation_context_rule_handler.GermanVacationContextRuleHandler( ) self.assertFalse( rule_handler.is_active(p_reference_date=datetime.datetime.strptime( "25.10.2020", "%d.%m.%Y").date(), p_details=VALID_STATE_NAME))
def test_invalid_state_name(self): rule_handler = german_vacation_context_rule_handler.GermanVacationContextRuleHandler( ) with self.assertRaises(configuration.ConfigurationException): rule_handler.is_active( p_reference_date=datetime.datetime.now().date(), p_details=INVALID_STATE_NAME)
def test_import_federal_states(self): rule_handler = german_vacation_context_rule_handler.GermanVacationContextRuleHandler() rule_handler.check_data() self.assertIsNotNone(rule_handler._federal_state_map) self.assertEqual(len(rule_handler._federal_state_map), 16) self.assertIn(VALID_STATE_NAME, rule_handler._federal_state_map)
def test_exception_when_invalid_vacation_data_url(self): rule_handler = german_vacation_context_rule_handler.GermanVacationContextRuleHandler() config = german_vacation_context_rule_handler.GermanVacationContextRuleHandlerConfig() config.vacation_data_url="INVALID" rule_handler._config = config with self.assertRaises(Exception): rule_handler.check_data()
def create_dummy_rule_handler(p_persistence, p_create_complex_handlers=True): default_context_rule_handler = simple_context_rule_handlers.DefaultContextRuleHandler() rulehandler_config = rule_handler.RuleHandlerConfigModel() a_rule_handler = rule_handler.RuleHandler(p_config=rulehandler_config, p_persistence=p_persistence) a_rule_handler.register_context_rule_handler(p_context_rule_handler=default_context_rule_handler, p_default=True) if p_create_complex_handlers: weekend_context_rule_handler = simple_context_rule_handlers.WeekplanContextRuleHandler() vacation_context_rule_handler = german_vacation_context_rule_handler.GermanVacationContextRuleHandler() a_rule_handler.register_context_rule_handler(p_context_rule_handler=weekend_context_rule_handler) a_rule_handler.register_context_rule_handler(p_context_rule_handler=vacation_context_rule_handler) return a_rule_handler
def create_dummy_rule_handler(p_ruleset_configs): default_context_rule_handler = simple_context_rule_handlers.DefaultContextRuleHandler( ) weekend_context_rule_handler = simple_context_rule_handlers.WeekdayContextRuleHandler( ) vacation_context_rule_handler = german_vacation_context_rule_handler.GermanVacationContextRuleHandler( ) rulehandler_config = rule_handler.RuleHandlerConfigModel() a_rule_handler = rule_handler.RuleHandler( p_config=rulehandler_config, p_rule_set_configs=p_ruleset_configs) a_rule_handler.register_context_rule_handler( p_context_rule_handler=default_context_rule_handler, p_default=True) a_rule_handler.register_context_rule_handler( p_context_rule_handler=weekend_context_rule_handler) a_rule_handler.register_context_rule_handler( p_context_rule_handler=vacation_context_rule_handler) return a_rule_handler
def test_is_active_last_day_of_vacation(self): rule_handler = german_vacation_context_rule_handler.GermanVacationContextRuleHandler() self.assertTrue(rule_handler.is_active(p_reference_date=datetime.datetime.strptime("21.10.2016", "%d.%m.%Y").date(), p_details=VALID_STATE_NAME))