def testScheduleAlternativeTrips(self):
        user_crontab = CronTab(user=True)
        user_crontab.remove_all()
        user_crontab.write()

        trip_iter = self.pipeline.get_trips_for_alternatives(self.testUUID)
        self.assertTrue(hasattr(trip_iter, "__iter__"))
        trip_list = list(trip_iter)
        firstElement = trip_list[0]
        self.assertTrue(isinstance(firstElement, ecwt.E_Mission_Trip))
        # calc_alternative_trips merely schedules the alternative trip calculation at a later time
        # it can't return the alternative trips right now
        pipeline_module.calc_alternative_trips(trip_list, immediate=False)
        for trip in trip_list:
            self.assertEqual(trip.pipelineFlags.alternativesStarted, True)

        # Re-open the crontab to see the new entries
        user_crontab = CronTab(user=True)
        jobs = [job for job in user_crontab]
        self.assertEqual(len(jobs), len(trip_list))
        self.assertEqual(jobs[0].hour, firstElement.start_time.hour)
Beispiel #2
0
 def runPipeline(self, immediate=False):
     for user_uuid in ec.get_uuid_list():
         logging.debug("Finding Trips for User: %s" % user_uuid)
         trips_with_no_alternatives = self.get_trips_for_alternatives(user_uuid)
         eatm.calc_alternative_trips(trips_with_no_alternatives, immediate)