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 testSegmentationWrapperWithManualTrip(self): ts = esta.TimeSeries.get_time_series(self.androidUUID) test_trip = ecwrt.Rawtrip() test_trip.start_ts = 1440695152.989 test_trip.start_fmt_time = "2015-08-27 10:05:52.989000-07:00" test_trip.start_local_dt = { 'year': 2015, 'month': 8, 'day': 27, 'hour': 10, 'minute': 5, 'second': 52, 'timezone': "America/Los_Angeles" } 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_local_dt = { 'year': 2015, 'month': 8, 'day': 27, 'hour': 11, 'minute': 14, 'second': 26, 'timezone': "America/Los_Angeles" } test_trip.end_loc = { "type": "Point", "coordinates": [-122.2603947, 37.875023] } test_trip_id = ts.insert( ecwe.Entry.create_entry(self.androidUUID, "segmentation/raw_trip", test_trip)) eaiss.segment_trip_into_sections(self.androidUUID, test_trip_id, "DwellSegmentationTimeFilter") created_stops_entries = esdt.get_raw_stops_for_trip( self.androidUUID, test_trip_id) created_sections_entries = esdt.get_raw_sections_for_trip( self.androidUUID, test_trip_id) created_stops = [entry.data for entry in created_stops_entries] created_sections = [entry.data for entry in created_sections_entries] tq_stop = estt.TimeQuery("data.enter_ts", 1440658800, 1440745200) queried_stops = esda.get_objects(esda.RAW_STOP_KEY, self.androidUUID, tq_stop) tq_section = estt.TimeQuery("data.start_ts", 1440658800, 1440745200) queried_sections = esda.get_objects(esda.RAW_SECTION_KEY, self.androidUUID, 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_entries[0].get_id()) self.assertEqual(created_stops[0].starting_section, created_sections_entries[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_entries[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_entries[0].get_id()) self.assertIsNone(created_sections[1].end_stop) self.assertEqual(created_sections, queried_sections) self.assertEqual(created_stops, queried_stops)
def testSegmentationWrapperWithManualTrip(self): ts = esta.TimeSeries.get_time_series(self.androidUUID) test_trip = ecwrt.Rawtrip() test_trip.start_ts = 1440695152.989 test_trip.start_fmt_time = "2015-08-27 10:05:52.989000-07:00" test_trip.start_local_dt = { 'year': 2015, 'month': 8, 'day': 27, 'hour': 10, 'minute': 5, 'second': 52, 'timezone': "America/Los_Angeles" } 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_local_dt = { 'year': 2015, 'month': 8, 'day': 27, 'hour': 11, 'minute': 14, 'second': 26, 'timezone': "America/Los_Angeles" } test_trip.end_loc = { "type": "Point", "coordinates": [ -122.2603947, 37.875023 ] } test_place = ecwrp.Rawplace() test_place.location = test_trip.start_loc test_place.exit_ts = test_trip.start_ts test_place.exit_local_dt = test_trip.start_local_dt test_place.exit_fmt_time = test_trip.start_fmt_time test_place_entry = ecwe.Entry.create_entry(self.androidUUID, "segmentation/raw_place", test_place) test_trip.start_place = test_place_entry.get_id() test_trip_id = ts.insert(ecwe.Entry.create_entry(self.androidUUID, "segmentation/raw_trip", test_trip)) test_trip_entry = ts.get_entry_from_id(esda.RAW_TRIP_KEY, test_trip_id) test_place.starting_trip = test_trip_id ts.insert(test_place_entry) eaiss.segment_trip_into_sections(self.androidUUID, test_trip_entry, "DwellSegmentationTimeFilter") created_stops_entries = esdt.get_raw_stops_for_trip(self.androidUUID, test_trip_id) created_sections_entries = esdt.get_raw_sections_for_trip(self.androidUUID, test_trip_id) created_stops = [entry.data for entry in created_stops_entries] created_sections = [entry.data for entry in created_sections_entries] tq_stop = estt.TimeQuery("data.enter_ts", 1440658800, 1440745200) queried_stops = esda.get_objects(esda.RAW_STOP_KEY, self.androidUUID, tq_stop) tq_section = estt.TimeQuery("data.start_ts", 1440658800, 1440745200) queried_sections = esda.get_objects(esda.RAW_SECTION_KEY, self.androidUUID, 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_entries[0].get_id()) self.assertEqual(created_stops[0].starting_section, created_sections_entries[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_entries[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_entries[0].get_id()) self.assertIsNone(created_sections[1].end_stop) self.assertEqual(created_sections, queried_sections) self.assertEqual(created_stops, queried_stops)
def testSegmentationWrapperWithManualTrip(self): ts = esta.TimeSeries.get_time_series(self.testUUID) test_trip = ecwrt.Rawtrip() 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 ] } test_trip_id = ts.insert(ecwe.Entry.create_entry(self.testUUID, "segmentation/raw_trip", test_trip)) eaiss.segment_trip_into_sections(self.testUUID, test_trip_id, "DwellSegmentationTimeFilter") created_stops_entries = esdt.get_raw_stops_for_trip(self.testUUID, test_trip_id) created_sections_entries = esdt.get_raw_sections_for_trip(self.testUUID, test_trip_id) created_stops = [entry.data for entry in created_stops_entries] created_sections = [entry.data for entry in created_sections_entries] tq_stop = estt.TimeQuery("data.enter_ts", 1440658800, 1440745200) queried_stops = esda.get_objects(esda.RAW_STOP_KEY, self.testUUID, tq_stop) tq_section = estt.TimeQuery("data.start_ts", 1440658800, 1440745200) queried_sections = esda.get_objects(esda.RAW_SECTION_KEY, 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_entries[0].get_id()) self.assertEqual(created_stops[0].starting_section, created_sections_entries[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_entries[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_entries[0].get_id()) self.assertIsNone(created_sections[1].end_stop) self.assertEqual(created_sections, queried_sections) self.assertEqual(created_stops, queried_stops)
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)