def test_json_3(self): agenda_config = [{AGENDA_NAME: "test_agenda", ITEMS_PROVIDED: ""}] init = Initializer(agenda_config) with self.assertRaises(JsonValidationException) as cm: init.initialize() the_exception = cm.exception self.assertEqual(str(the_exception), "'items_provided' is not a list")
def test_json_2(self): agenda_config = [{ AGENDA_NAME: "test_agenda", }] init = Initializer(agenda_config) with self.assertRaises(JsonValidationException) as cm: init.initialize() the_exception = cm.exception self.assertEqual(str(the_exception), "Missing 'items_provided' in Config Json")
def test_json_1(self): agenda_config = [ { ITEMS_PROVIDED: [] }, ] init = Initializer(agenda_config) with self.assertRaises(JsonValidationException) as cm: init.initialize() the_exception = cm.exception self.assertEqual(str(the_exception), "Missing 'agenda_name' in Config Json")
def test_json_7(self): agenda_config = [{AGENDA_NAME: "test_agenda", ITEMS_PROVIDED: [int]}] init = Initializer(agenda_config) init.initialize() ins = RuleConfigs() self.assertEqual(ins.get_rule_config(), agenda_config)
def test_json_6(self): init = Initializer(" ") with self.assertRaises(InitializeException) as cm: init.initialize() the_exception = cm.exception self.assertEqual(str(the_exception), "Invalid type of Config List")
def test_json_5(self): init = Initializer(None) with self.assertRaises(InitializeException) as cm: init.initialize() the_exception = cm.exception self.assertEqual(str(the_exception), "Config List cannot be empty")
from example.agendaConfig import agenda_config from example.importList import import_list from example.selfDefinedClass import TestClass from pysrules.agendprepare import AgendaPreparer from pysrules.initializer import Initializer from pysrules.ruleReloader import RuleReloader from pysrules.ruleexecutor import RuleExecutor if __name__ == '__main__': init = Initializer(agenda_config) init.initialize() reloader = RuleReloader(import_list) reloader.reload() preparer = AgendaPreparer() test_ins = TestClass() test_ins.a = 1 ai = preparer.prepare_agenda("test_agenda", test_ins) executor = RuleExecutor() executor.execute_all(ai) preparer2 = AgendaPreparer() test_ins.a = 2 ai2 = preparer.prepare_agenda("test_agenda", test_ins) executor.execute_all(ai2)