def testSegmentationWrapperWithManualTrip(self): test_trip = esdt.create_new_trip(self.testUUID) test_trip.start_ts = 1440695152.989 test_trip.start_fmt_time = "2015-08-27 10:05:52.989000-07:00" test_trip.start_loc = { "type": "Point", "coordinates": [ -122.4029569, 37.6162024 ] } test_trip.end_ts = 1440699266.669 test_trip.end_fmt_time = "2015-08-27 11:14:26.669000-07:00" test_trip.end_loc = { "type": "Point", "coordinates": [ -122.2603947, 37.875023 ] } esdt.save_trip(test_trip) eaiss.segment_trip_into_sections(self.testUUID, test_trip.get_id(), "DwellSegmentationTimeFilter") created_stops = esdt.get_stops_for_trip(self.testUUID, test_trip.get_id()) created_sections = esdt.get_sections_for_trip(self.testUUID, test_trip.get_id()) tq_stop = enua.UserCache.TimeQuery("enter_ts", 1440658800, 1440745200) queried_stops = esdst.get_stops(self.testUUID, tq_stop) tq_section = enua.UserCache.TimeQuery("start_ts", 1440658800, 1440745200) queried_sections = esds.get_sections(self.testUUID, tq_section) for i, stop in enumerate(created_stops): logging.info("Retrieved stop %s: %s -> %s" % (i, stop.enter_fmt_time, stop.exit_fmt_time)) for i, section in enumerate(created_sections): logging.info("Retrieved section %s: %s -> %s" % (i, section.start_fmt_time, section.end_fmt_time)) self.assertEqual(len(created_stops), 1) self.assertEqual(created_stops[0].enter_ts, 1440698066.704) self.assertEqual(created_stops[0].exit_ts, 1440698306.892) self.assertEqual(created_stops[0].exit_loc, created_sections[1].start_loc) self.assertEqual(created_stops[0].ending_section, created_sections[0].get_id()) self.assertEqual(created_stops[0].starting_section, created_sections[1].get_id()) self.assertEqual(len(created_sections), 2) logging.info("Checking fields for section %s" % created_sections[0]) self.assertEqual(created_sections[0].start_ts, 1440695152.989) self.assertEqual(created_sections[0].end_ts, 1440698066.704) self.assertIsNone(created_sections[0].start_stop) self.assertEqual(created_sections[0].end_stop, created_stops[0].get_id()) logging.info("Checking fields for section %s" % created_sections[1]) self.assertEqual(created_sections[1].start_ts, 1440698306.892) self.assertEqual(created_sections[1].end_ts, 1440699266.669) self.assertEqual(created_sections[1].start_stop, created_stops[0].get_id()) self.assertIsNone(created_sections[1].end_stop) self.assertEqual(created_sections, queried_sections) self.assertEqual(created_stops, queried_stops)
def testQueryStops(self): new_stop = esds.create_new_stop(self.testUserId, self.test_trip_id) new_stop.enter_ts = 5 new_stop.exit_ts = 6 esds.save_stop(new_stop) ret_arr_one = esds.get_stops_for_trip(self.testUserId, self.test_trip_id) self.assertEqual(len(ret_arr_one), 1) self.assertEqual(ret_arr_one, [new_stop]) ret_arr_list = esds.get_stops_for_trip_list(self.testUserId, [self.test_trip_id]) self.assertEqual(ret_arr_one, ret_arr_list) ret_arr_time = esds.get_stops(self.testUserId, enua.UserCache.TimeQuery("enter_ts", 4, 6)) self.assertEqual(ret_arr_list, ret_arr_time)
def testQueryStops(self): new_stop = esds.create_new_stop(self.testUserId, self.test_trip_id) new_stop.enter_ts = 5 new_stop.exit_ts = 6 esds.save_stop(new_stop) ret_arr_one = esds.get_stops_for_trip(self.testUserId, self.test_trip_id) self.assertEqual(len(ret_arr_one), 1) self.assertEqual(ret_arr_one, [new_stop]) ret_arr_list = esds.get_stops_for_trip_list(self.testUserId, [self.test_trip_id]) self.assertEqual(ret_arr_one, ret_arr_list) ret_arr_time = esds.get_stops( self.testUserId, enua.UserCache.TimeQuery("enter_ts", 4, 6)) self.assertEqual(ret_arr_list, ret_arr_time)
def testSegmentationWrapperWithManualTrip(self): test_trip = esdt.create_new_trip(self.testUUID) test_trip.start_ts = 1440695152.989 test_trip.start_fmt_time = "2015-08-27 10:05:52.989000-07:00" test_trip.start_loc = { "type": "Point", "coordinates": [-122.4029569, 37.6162024] } test_trip.end_ts = 1440699266.669 test_trip.end_fmt_time = "2015-08-27 11:14:26.669000-07:00" test_trip.end_loc = { "type": "Point", "coordinates": [-122.2603947, 37.875023] } esdt.save_trip(test_trip) eaiss.segment_trip_into_sections(self.testUUID, test_trip.get_id(), "DwellSegmentationTimeFilter") created_stops = esdt.get_stops_for_trip(self.testUUID, test_trip.get_id()) created_sections = esdt.get_sections_for_trip(self.testUUID, test_trip.get_id()) tq_stop = enua.UserCache.TimeQuery("enter_ts", 1440658800, 1440745200) queried_stops = esdst.get_stops(self.testUUID, tq_stop) tq_section = enua.UserCache.TimeQuery("start_ts", 1440658800, 1440745200) queried_sections = esds.get_sections(self.testUUID, tq_section) for i, stop in enumerate(created_stops): logging.info("Retrieved stop %s: %s -> %s" % (i, stop.enter_fmt_time, stop.exit_fmt_time)) for i, section in enumerate(created_sections): logging.info("Retrieved section %s: %s -> %s" % (i, section.start_fmt_time, section.end_fmt_time)) self.assertEqual(len(created_stops), 1) self.assertEqual(created_stops[0].enter_ts, 1440698066.704) self.assertEqual(created_stops[0].exit_ts, 1440698306.892) self.assertEqual(created_stops[0].exit_loc, created_sections[1].start_loc) self.assertEqual(created_stops[0].ending_section, created_sections[0].get_id()) self.assertEqual(created_stops[0].starting_section, created_sections[1].get_id()) self.assertEqual(len(created_sections), 2) logging.info("Checking fields for section %s" % created_sections[0]) self.assertEqual(created_sections[0].start_ts, 1440695152.989) self.assertEqual(created_sections[0].end_ts, 1440698066.704) self.assertIsNone(created_sections[0].start_stop) self.assertEqual(created_sections[0].end_stop, created_stops[0].get_id()) logging.info("Checking fields for section %s" % created_sections[1]) self.assertEqual(created_sections[1].start_ts, 1440698306.892) self.assertEqual(created_sections[1].end_ts, 1440699266.669) self.assertEqual(created_sections[1].start_stop, created_stops[0].get_id()) self.assertIsNone(created_sections[1].end_stop) self.assertEqual(created_sections, queried_sections) self.assertEqual(created_stops, queried_stops)