def setUp(self): # Make sure we start with a clean slate every time self.serverName = 'localhost' common.dropAllCollections(get_db()) logging.info("After setup, client count = %d, profile count = %d, uuid count = %d" % (get_client_db().find().count(), get_profile_db().count(), get_uuid_db().count())) common.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json")
def setUp(self): self.testUsers = [ "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" ] self.serverName = 'localhost' # Sometimes, we may have entries left behind in the database if one of the tests failed # or threw an exception, so let us start by cleaning up all entries etc.dropAllCollections(edb._get_current_db()) self.ModesColl = get_mode_db() self.assertEquals(self.ModesColl.find().count(), 0) self.SectionsColl = get_section_db() self.assertEquals(self.SectionsColl.find().count(), 0) etc.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json") etc.loadTable(self.serverName, "Stage_Sections", "emission/tests/data/testModeInferFile") # Let's make sure that the users are registered so that they have profiles for userEmail in self.testUsers: User.register(userEmail) self.now = datetime.now() self.dayago = self.now - timedelta(days=1) self.weekago = self.now - timedelta(weeks=1) for section in self.SectionsColl.find(): section['section_start_datetime'] = self.dayago section['section_end_datetime'] = self.dayago + timedelta(hours=1) if (section['confirmed_mode'] == 5): # We only cluster bus and train trips # And our test data only has bus trips section['section_start_point'] = { u'type': u'Point', u'coordinates': [-122.270039042, 37.8800285728] } section['section_end_point'] = { u'type': u'Point', u'coordinates': [-122.2690412952, 37.8739578595] } # print("Section start = %s, section end = %s" % # (section['section_start_datetime'], section['section_end_datetime'])) # Replace the user email with the UUID section['user_id'] = User.fromEmail(section['user_id']).uuid self.SectionsColl.save(section) self.pipeline = pipeline.ModeInferencePipeline() self.testLoadTrainingData()
def setUp(self): # Make sure we start with a clean slate every time self.serverName = 'localhost' common.dropAllCollections(edb._get_current_db()) import shutil self.config_path = "conf/clients/testclient.settings.json" shutil.copyfile("%s.sample" % self.config_path, self.config_path) logging.info("After setup, client count = %d, profile count = %d, uuid count = %d" % (get_client_db().find().count(), get_profile_db().count(), get_uuid_db().count())) common.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json")
def setUp(self): # Make sure we start with a clean slate every time self.serverName = 'localhost' common.dropAllCollections(edb._get_current_db()) import shutil self.config_path = "conf/clients/testclient.settings.json" shutil.copyfile("%s.sample" % self.config_path, self.config_path) logging.info("After setup, client count = %d, profile count = %d, uuid count = %d" % (get_client_db().estimated_document_count(), get_profile_db().estimated_document_count(), get_uuid_db().estimated_document_count())) common.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json")
def setUp(self): import emission.tests.common as etc etc.dropAllCollections(edb._get_current_db()) self.testUserUUID1 = uuid.uuid4() self.testUserUUID2 = uuid.uuid4() self.testUserUUIDios = uuid.uuid4() (self.entry_list, self.ios_entry_list) = etc.setupIncomingEntries() self.uc1 = enua.UserCache.getUserCache(self.testUserUUID1) self.uc2 = enua.UserCache.getUserCache(self.testUserUUID2) self.ucios = enua.UserCache.getUserCache(self.testUserUUIDios) self.ts1 = esta.TimeSeries.get_time_series(self.testUserUUID1) self.ts2 = esta.TimeSeries.get_time_series(self.testUserUUID2) self.tsios = esta.TimeSeries.get_time_series(self.testUserUUIDios) for entry in self.entry_list: # Needed because otherwise we get a DuplicateKeyError while # inserting the mutiple copies del entry["_id"] self.curr_ts = int(time.time()) for offset in range(self.curr_ts - 5 * 60, self.curr_ts, 30): for entry in self.entry_list: entry["metadata"]["write_ts"] = offset mauc.sync_phone_to_server(self.testUserUUID1, self.entry_list) for offset in range(self.curr_ts - 7 * 60 + 1, self.curr_ts - 2 * 60 + 1, 30): for entry in self.entry_list: entry["metadata"]["write_ts"] = offset mauc.sync_phone_to_server(self.testUserUUID2, self.entry_list) for entry in self.ios_entry_list: # Needed because otherwise we get a DuplicateKeyError while # inserting the mutiple copies del entry["_id"] for offset in range(self.curr_ts - 5 * 60, self.curr_ts, 30): for entry in self.ios_entry_list: entry["metadata"]["write_ts"] = offset mauc.sync_phone_to_server(self.testUserUUIDios, self.ios_entry_list)
def setUp(self): from copy import copy self.testUsers = [ "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" ] self.serverName = 'localhost' # Sometimes, we may have entries left behind in the database if one of the tests failed # or threw an exception, so let us start by cleaning up all entries etc.dropAllCollections(get_db()) self.ModesColl = get_mode_db() self.assertEquals(self.ModesColl.find().count(), 0) etc.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json") etc.loadTable(self.serverName, "Stage_Sections", "emission/tests/data/testCarbonFile") self.SectionsColl = get_section_db() self.walkExpect = 1057.2524056424411 self.busExpect = 2162.668467546699 self.busCarbon = 267.0 / 1609 self.airCarbon = 217.0 / 1609 self.driveCarbon = 278.0 / 1609 self.busOptimalCarbon = 92.0 / 1609 self.now = datetime.now() self.dayago = self.now - timedelta(days=1) self.weekago = self.now - timedelta(weeks=1) for section in self.SectionsColl.find(): section['section_start_datetime'] = self.dayago section['section_end_datetime'] = self.dayago + timedelta(hours=1) if section['confirmed_mode'] == 5: airSection = copy(section) airSection['confirmed_mode'] = 9 airSection['_id'] = section['_id'] + "_air" self.SectionsColl.insert(airSection) # print("Section start = %s, section end = %s" % # (section['section_start_datetime'], section['section_end_datetime'])) self.SectionsColl.save(section)
def setUp(self): self.testUsers = ["*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**"] self.serverName = 'localhost' # Sometimes, we may have entries left behind in the database if one of the tests failed # or threw an exception, so let us start by cleaning up all entries etc.dropAllCollections(edb._get_current_db()) self.ModesColl = get_mode_db() self.assertEquals(self.ModesColl.find().count(), 0) self.SectionsColl = get_section_db() self.assertEquals(self.SectionsColl.find().count(), 0) etc.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json") etc.loadTable(self.serverName, "Stage_Sections", "emission/tests/data/testModeInferFile") # Let's make sure that the users are registered so that they have profiles for userEmail in self.testUsers: User.register(userEmail) self.now = datetime.now() self.dayago = self.now - timedelta(days=1) self.weekago = self.now - timedelta(weeks = 1) for section in self.SectionsColl.find(): section['section_start_datetime'] = self.dayago section['section_end_datetime'] = self.dayago + timedelta(hours = 1) if (section['confirmed_mode'] == 5): # We only cluster bus and train trips # And our test data only has bus trips section['section_start_point'] = {u'type': u'Point', u'coordinates': [-122.270039042, 37.8800285728]} section['section_end_point'] = {u'type': u'Point', u'coordinates': [-122.2690412952, 37.8739578595]} # print("Section start = %s, section end = %s" % # (section['section_start_datetime'], section['section_end_datetime'])) # Replace the user email with the UUID section['user_id'] = User.fromEmail(section['user_id']).uuid self.SectionsColl.save(section) self.pipeline = pipeline.ModeInferencePipeline() self.testLoadTrainingData()
def setUp(self): from copy import copy self.testUsers = ["*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**"] self.serverName = 'localhost' # Sometimes, we may have entries left behind in the database if one of the tests failed # or threw an exception, so let us start by cleaning up all entries etc.dropAllCollections(get_db()) self.ModesColl = get_mode_db() self.assertEquals(self.ModesColl.find().count(), 0) etc.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json") etc.loadTable(self.serverName, "Stage_Sections", "emission/tests/data/testCarbonFile") self.SectionsColl = get_section_db() self.walkExpect = 1057.2524056424411 self.busExpect = 2162.668467546699 self.busCarbon = 267.0/1609 self.airCarbon = 217.0/1609 self.driveCarbon = 278.0/1609 self.busOptimalCarbon = 92.0/1609 self.now = datetime.now() self.dayago = self.now - timedelta(days=1) self.weekago = self.now - timedelta(weeks = 1) for section in self.SectionsColl.find(): section['section_start_datetime'] = self.dayago section['section_end_datetime'] = self.dayago + timedelta(hours = 1) if section['confirmed_mode'] == 5: airSection = copy(section) airSection['confirmed_mode'] = 9 airSection['_id'] = section['_id'] + "_air" self.SectionsColl.insert(airSection) # print("Section start = %s, section end = %s" % # (section['section_start_datetime'], section['section_end_datetime'])) self.SectionsColl.save(section)
def setUp(self): etc.dropAllCollections(edb.get_db())
def purgeAllData(): db = edb._get_current_db() etc.dropAllCollections(db)
def setUp(self): import emission.core.get_database as edb common.dropAllCollections(edb.get_db())
def setUp(self): etc.dropAllCollections(edb._get_current_db())
def purgeAllData(): db = get_db() common.dropAllCollections(db)
def purgeAllData(): db = get_db() etc.dropAllCollections(db)