Esempio n. 1
0
 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")
Esempio n. 2
0
 def setUp(self):
     import emission.tests.common
     # 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
     emission.tests.common.dropAllCollections(get_db())
     user = User.register("*****@*****.**")
     self.uuid = user.uuid
Esempio n. 3
0
    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
        emission.tests.common.dropAllCollections(get_db())
        self.ModesColl = get_mode_db()
        # self.ModesColl.remove()
        self.assertEquals(self.ModesColl.find().count(), 0)

        self.SectionsColl = get_section_db()
        # self.SectionsColl.remove()
        self.assertEquals(self.SectionsColl.find().count(), 0)

        emission.tests.common.loadTable(self.serverName, "Stage_Modes",
                                        "emission/tests/data/modes.json")
        emission.tests.common.loadTable(self.serverName, "Stage_Sections",
                                        "emission/tests/data/testCarbonFile")

        # Let's make sure that the users are registered so that they have profiles
        for userEmail in self.testUsers:
            User.register(userEmail)

        self.walkExpect = 1057.2524056424411
        self.busExpect = 2162.668467546699
        self.busCarbon = 267.0 / 1609

        self.now = datetime.now()
        self.dayago = self.now - timedelta(days=1)
        self.weekago = self.now - timedelta(weeks=1)
        emission.tests.common.updateSections(self)
Esempio n. 4
0
 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")
Esempio n. 5
0
 def setUp(self):
     import emission.tests.common
     # 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
     emission.tests.common.dropAllCollections(get_db())
     user = User.register("*****@*****.**")
     self.uuid = user.uuid
  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
    emission.tests.common.dropAllCollections(get_db())
    self.ModesColl = get_mode_db()
    # self.ModesColl.remove()
    self.assertEquals(self.ModesColl.find().count(), 0)

    self.SectionsColl = get_section_db()
    # self.SectionsColl.remove()
    self.assertEquals(self.SectionsColl.find().count(), 0)

    emission.tests.common.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json")
    emission.tests.common.loadTable(self.serverName, "Stage_Sections", "emission/tests/data/testCarbonFile")

    # Let's make sure that the users are registered so that they have profiles
    for userEmail in self.testUsers:
      User.register(userEmail)

    self.walkExpect = 1057.2524056424411
    self.busExpect = 2162.668467546699
    self.busCarbon = 267.0/1609

    self.now = datetime.now()
    self.dayago = self.now - timedelta(days=1)
    self.weekago = self.now - timedelta(weeks = 1)
    emission.tests.common.updateSections(self)
Esempio n. 7
0
    def setUp(self):
        import emission.tests.common
        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
        emission.tests.common.dropAllCollections(get_db())
        self.ModesColl = get_mode_db()
        self.assertEquals(self.ModesColl.find().count(), 0)

        self.setupUserAndClient()

        emission.tests.common.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json")
        emission.tests.common.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.allDriveExpect = (self.busExpect * self.driveCarbon + self.walkExpect * self.driveCarbon)/1000
        self.myFootprintExpect = float(self.busExpect * self.busCarbon)/1000
        self.sb375GoalExpect = 40.142892/7

        self.mineMinusOptimalExpect = 0
        self.allDriveMinusMineExpect = float(self.allDriveExpect - self.myFootprintExpect)/self.allDriveExpect
        self.sb375DailyGoalMinusMineExpect = float(self.sb375GoalExpect - self.myFootprintExpect)/self.sb375GoalExpect

        self.now = datetime.now()
        self.twodaysago = self.now - timedelta(days=2)
        self.weekago = self.now - timedelta(weeks = 1)

        for section in self.SectionsColl.find():
            section['section_start_datetime'] = self.twodaysago
            section['section_end_datetime'] = self.twodaysago + timedelta(hours = 1)
            section['predicted_mode'] = {'walking': 1.0}
            if section['user_id'] == '*****@*****.**':
                logging.debug("Setting user_id for section %s, %s = %s" %
                    (section['trip_id'], section['section_id'], self.user.uuid))
                section['user_id'] = self.user.uuid
            if section['confirmed_mode'] == 5:
                airSection = copy(section)
                airSection['confirmed_mode'] = 9
                airSection['_id'] = section['_id'] + "_air"
                self.SectionsColl.insert(airSection)
                airSection['confirmed_mode'] = ''
                airSection['_id'] = section['_id'] + "_unconf"
                self.SectionsColl.insert(airSection)
          
            # print("Section start = %s, section end = %s" %
            #   (section['section_start_datetime'], section['section_end_datetime']))
            self.SectionsColl.save(section)
Esempio n. 8
0
 def setUp(self):
     # 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
     emission.tests.common.dropAllCollections(get_db())
     user = User.register("*****@*****.**")
     self.uuid = user.uuid
     self.serverName = "localhost"
     self.now = datetime.now()
     self.dayago = self.now - timedelta(days=1)
     self.weekago = self.now - timedelta(weeks = 1)
Esempio n. 9
0
 def setUp(self):
     # 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
     emission.tests.common.dropAllCollections(get_db())
     user = User.register("*****@*****.**")
     self.uuid = user.uuid
     self.serverName = "localhost"
     self.now = datetime.now()
     self.dayago = self.now - timedelta(days=1)
     self.weekago = self.now - timedelta(weeks=1)
Esempio n. 10
0
  def setUp(self):
    import emission.tests.common

    self.serverName = 'localhost'

    # Make sure we start with a clean slate every time
    emission.tests.common.dropAllCollections(get_database.get_db())
    
    # Load modes, otherwise the queries won't work properly
    emission.tests.common.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json")
    self.dayago = datetime.now() - timedelta(days=1)
    self.now = datetime.now()
Esempio n. 11
0
    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
        emission.tests.common.dropAllCollections(get_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)

        emission.tests.common.loadTable(self.serverName, "Stage_Modes",
                                        "emission/tests/data/modes.json")
        emission.tests.common.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()
Esempio n. 12
0
    def setUp(self):
        import emission.tests.common

        self.serverName = 'localhost'

        # Make sure we start with a clean slate every time
        emission.tests.common.dropAllCollections(get_database.get_db())

        # Load modes, otherwise the queries won't work properly
        emission.tests.common.loadTable(self.serverName, "Stage_Modes",
                                        "emission/tests/data/modes.json")
        self.dayago = datetime.now() - timedelta(days=1)
        self.now = datetime.now()
    def setUp(self):
        emission.tests.common.dropAllCollections(edb.get_db())
        self.testUserUUID1 = uuid.uuid4()
        self.testUserUUID2 = uuid.uuid4()
        self.testUserUUIDios = uuid.uuid4()
        
        self.activity_entry = json.load(open("emission/tests/data/netTests/android.activity.txt"))
        self.location_entry = json.load(open("emission/tests/data/netTests/android.location.raw.txt"))
        self.transition_entry = json.load(open("emission/tests/data/netTests/android.transition.txt"))
        self.entry_list = [self.activity_entry, self.location_entry, self.transition_entry]

        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 * 1000
            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 * 1000
            mauc.sync_phone_to_server(self.testUserUUID2, self.entry_list)
            
        self.ios_activity_entry = json.load(open("emission/tests/data/netTests/ios.activity.txt"))
        self.ios_location_entry = json.load(open("emission/tests/data/netTests/ios.location.txt"))
        self.ios_transition_entry = json.load(open("emission/tests/data/netTests/ios.transition.txt"))
        self.ios_entry_list = [self.ios_activity_entry, self.ios_location_entry, self.ios_transition_entry]
        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):
        emission.tests.common.dropAllCollections(edb.get_db())
        self.testUserUUID1 = uuid.uuid4()
        self.testUserUUID2 = uuid.uuid4()
        self.testUserUUIDios = uuid.uuid4()
        
        self.activity_entry = json.load(open("emission/tests/data/netTests/android.activity.txt"))
        self.location_entry = json.load(open("emission/tests/data/netTests/android.location.raw.txt"))
        self.transition_entry = json.load(open("emission/tests/data/netTests/android.transition.txt"))
        self.entry_list = [self.activity_entry, self.location_entry, self.transition_entry]

        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 * 1000
            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 * 1000
            mauc.sync_phone_to_server(self.testUserUUID2, self.entry_list)
            
        self.ios_activity_entry = json.load(open("emission/tests/data/netTests/ios.activity.txt"))
        self.ios_location_entry = json.load(open("emission/tests/data/netTests/ios.location.txt"))
        self.ios_transition_entry = json.load(open("emission/tests/data/netTests/ios.transition.txt"))
        self.ios_entry_list = [self.ios_activity_entry, self.ios_location_entry, self.ios_transition_entry]
        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):
        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
        emission.tests.common.dropAllCollections(get_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)

        emission.tests.common.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json")
        emission.tests.common.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()
Esempio n. 16
0
    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):
    import emission.tests.common
    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
    emission.tests.common.dropAllCollections(get_db())
    self.ModesColl = get_mode_db()
    self.assertEquals(self.ModesColl.find().count(), 0)

    emission.tests.common.loadTable(self.serverName, "Stage_Modes", "emission/tests/data/modes.json")
    emission.tests.common.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)
      # Note that we currently only search by the date/time of the section, not the points.
      # If we ever change that, this test will start failing and will need to be fixed as well
      track_pt_array = []
      for i in range(10):
          track_pt_array.append({'time': '20140829T170451-0700',
                 'track_location': {'coordinates': [-122.114642519, 37.4021455446],
                                            'type': 'Point'}})
          track_pt_array.append({'time': '20140829T170620-0700',
                   'track_location': {'coordinates': [-122.1099155383, 37.399523614],
                    'type': 'Point'}})
      section['track_points'] = track_pt_array
      self.SectionsColl.save(section)
Esempio n. 18
0
  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 tearDown(self):
   emission.tests.common.dropAllCollections(get_db())
 def setUp(self):
   self.testUserUUID = uuid.uuid4()
   emission.tests.common.dropAllCollections(get_db())
Esempio n. 21
0
def loadTable(serverName, tableName, fileName):
  tableColl = get_db()[tableName]
  dataJSON = json.load(open(fileName))
  for row in dataJSON:
    tableColl.insert(row)
Esempio n. 22
0
def purgeAllData():
    db = get_db()
    etc.dropAllCollections(db)
Esempio n. 23
0
    def setUp(self):
        import emission.tests.common
        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
        emission.tests.common.dropAllCollections(get_db())
        self.ModesColl = get_mode_db()
        self.assertEquals(self.ModesColl.find().count(), 0)

        self.setupUserAndClient()

        emission.tests.common.loadTable(self.serverName, "Stage_Modes",
                                        "emission/tests/data/modes.json")
        emission.tests.common.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.allDriveExpect = (self.busExpect * self.driveCarbon +
                               self.walkExpect * self.driveCarbon) / 1000
        self.myFootprintExpect = float(self.busExpect * self.busCarbon) / 1000
        self.sb375GoalExpect = 40.142892 / 7

        self.mineMinusOptimalExpect = 0
        self.allDriveMinusMineExpect = float(
            self.allDriveExpect - self.myFootprintExpect) / self.allDriveExpect
        self.sb375DailyGoalMinusMineExpect = float(
            self.sb375GoalExpect -
            self.myFootprintExpect) / self.sb375GoalExpect

        self.now = datetime.now()
        self.twodaysago = self.now - timedelta(days=2)
        self.weekago = self.now - timedelta(weeks=1)

        for section in self.SectionsColl.find():
            section['section_start_datetime'] = self.twodaysago
            section['section_end_datetime'] = self.twodaysago + timedelta(
                hours=1)
            section['predicted_mode'] = {'walking': 1.0}
            if section['user_id'] == '*****@*****.**':
                logging.debug("Setting user_id for section %s, %s = %s" %
                              (section['trip_id'], section['section_id'],
                               self.user.uuid))
                section['user_id'] = self.user.uuid
            if section['confirmed_mode'] == 5:
                airSection = copy(section)
                airSection['confirmed_mode'] = 9
                airSection['_id'] = section['_id'] + "_air"
                self.SectionsColl.insert(airSection)
                airSection['confirmed_mode'] = ''
                airSection['_id'] = section['_id'] + "_unconf"
                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.testUserUUID = uuid.uuid4()
     emission.tests.common.dropAllCollections(get_db())
Esempio n. 25
0
 def setUp(self):
     import emission.core.get_database as edb
     common.dropAllCollections(edb.get_db())
Esempio n. 26
0
 def setUp(self):
   etc.dropAllCollections(edb.get_db())
Esempio n. 27
0
def purgeAllData():
    db = get_db()
    common.dropAllCollections(db)
Esempio n. 28
0
 def setUp(self):
   import emission.core.get_database as edb
   common.dropAllCollections(edb.get_db())
Esempio n. 29
0
 def setUp(self):
     etc.dropAllCollections(edb.get_db())
 def tearDown(self):
     emission.tests.common.dropAllCollections(get_db())
def purgeAllData():
  db = get_db()
  common.dropAllCollections(db)