def test_DaysToRun_WhenNotInDaysToRun_ShouldNotInitialiazeTheProcess(self): xml_s = '''<?xml version="1.0"?> <Primo> <Parameters> <Parameter name="workdays" value="mon,tu,wed,th,fri" /> </Parameters> <Process bin="''' + TEST_PROCESS_PATH + '''" id="tio_log_replay"> <DaysToRun days="{workdays}" /> </Process> </Primo> ''' args = [] x = primo.XmlConfigParser(args) testing_object = x.parse_string(xml_s) primo_t = threading.Thread(target=PrimoWorkerFnc, args=(testing_object, )) primo_t.daemon = True primo_t.start() primo_t.join(2) proc = testing_object.processes['tio_log_replay'] # Chama Stop do primo para sair do loop principal testing_object.Stop() self.assertTrue(proc is not None) self.assertEqual(False, proc.running) self.assertTrue(proc.days_to_run is not None)
def test_DaysNotToRunAndDaysToRun_WhenInDaysToRun_ShouldInitializeTheProcess( self): xml_s = '''<?xml version="1.0"?> <Primo> <Parameters> <Parameter name="mockdays" value="2019-12-7" /> <Parameter name="weekend" value="sun,sat" /> </Parameters> <Process bin="''' + TEST_PROCESS_PATH + '''" id="tio_log_replay"> <DaysNotToRun days="{mockdays}" /> <DaysToRun days="{weekend}" /> </Process> </Primo> ''' args = [] x = primo.XmlConfigParser(args) testing_object = x.parse_string(xml_s) primo_t = threading.Thread(target=PrimoWorkerFnc, args=(testing_object, )) primo_t.daemon = True primo_t.start() primo_t.join(2) proc = testing_object.processes['tio_log_replay'] testing_object.Stop() self.assertTrue(proc is not None) self.assertEqual(True, proc.running) self.assertTrue(proc.days_to_run is not None) self.assertTrue(proc.days_not_to_run is not None)
def test_RunningPeriod_WhenInPeriod_ShouldInitializeTheProcess(self): xml_s = '''<?xml version="1.0"?> <Primo> <Parameters> <Parameter name="weekend" value="sun,sat" /> <Parameter name="tio_log_replay_start_time" value="06:55:00" /> <Parameter name="tio_log_replay_end_time" value="07:05:00"/> </Parameters> <Process bin="''' + TEST_PROCESS_PATH + '''" id="tio_log_replay"> <RunningPeriod start="{tio_log_replay_start_time}" end="{tio_log_replay_end_time}"/> </Process> </Primo> ''' args = [] x = primo.XmlConfigParser(args) testing_object = x.parse_string(xml_s) primo_t = threading.Thread(target=PrimoWorkerFnc, args=(testing_object, )) primo_t.daemon = True primo_t.start() primo_t.join(2) proc = testing_object.processes['tio_log_replay'] testing_object.Stop() self.assertTrue(proc is not None) self.assertEqual(True, proc.running) self.assertTrue(proc.running_period is not None)
def test_OnSpecificTime_WhenNotOnSpecificTime_ShouldNotInitialiazeTheProcess( self): xml_s = '''<?xml version="1.0"?> <Primo> <Parameters> <Parameter name="tio_log_replay_start_time" value="06:54:00" /> </Parameters> <Process bin="''' + TEST_PROCESS_PATH + '''" id="tio_log_replay"> <OnSpecificTime time="{tio_log_replay_start_time}" action="{process.Start()}" /> </Process> </Primo> ''' args = [] x = primo.XmlConfigParser(args) testing_object = x.parse_string(xml_s) primo_t = threading.Thread(target=PrimoWorkerFnc, args=(testing_object, )) primo_t.daemon = True primo_t.start() primo_t.join(2) proc = testing_object.processes['tio_log_replay'] testing_object.Stop() self.assertTrue(proc is not None) self.assertEqual(False, proc.running) self.assertTrue(proc.on_specific_time is not None)