示例#1
0
 def testStoreClientEntry(self):
     currTime = time.time()
     self.assertEqual(get_client_stats_db().find().count(), 0)
     stats.storeClientEntry("testuser", "testfield", currTime, 0.002, {"metadata_key": "metadata_val"})
     self.assertEqual(get_client_stats_db().find().count(), 1)
     self.assertEqual(get_client_stats_db().find({"user": "******"}).count(), 1)
     self.assertEqual(get_client_stats_db().find({"ts": currTime}).count(), 1)
示例#2
0
 def testStoreClientEntry(self):
   currTime = time.time()
   self.assertEqual(get_client_stats_db().query_tags(), None)
   
   success = stats.storeClientEntry("testuser", "testfield", currTime, 0.002, {"metadata_key": "metadata_val"})
   savedEntries = get_client_stats_db().query_tags()
   self.assertEquals(type(savedEntries), list)
   self.assertEquals(len(savedEntries), 1)
   entry = savedEntries[0]
   self.assertEquals(entry["Metadata"]["metadata_key"], "metadata_val")
def storeClientEntries(fname):
	df = pandas.read_csv(fname)
	for c in range(len(df)):
		try:
			user = df['user'][c]
			stat = df['stat'][c]
			ts = int(float(df['client_ts'][c]))
			reading = df['reading'][c]
			if reading.lower() == 'none':
				reading = 1.0
			else:
				reading = float(reading)
			metadata = {}
			for key in df:
				if key not in ['user', 'stat', 'client_ts', 'reading']:
					metadata[key] = df[key][c]
			storeClientEntry(user, stat, ts, reading, metadata)
		except Exception as e:
			print(e)
			#print(df['reading'][c] == 'None')
			print(df['reading'][c] == 'None')
示例#4
0
    def testStoreClientEntry(self):
        currTime = time.time()
        self.assertEqual(get_client_stats_db().query_tags(), None)

        success = stats.storeClientEntry("testuser", "testfield", currTime,
                                         0.002,
                                         {"metadata_key": "metadata_val"})
        savedEntries = get_client_stats_db().query_tags()
        self.assertEquals(type(savedEntries), list)
        self.assertEquals(len(savedEntries), 1)
        entry = savedEntries[0]
        self.assertEquals(entry["Metadata"]["metadata_key"], "metadata_val")
示例#5
0
def storeClientEntries(fname):
    df = pandas.read_csv(fname)
    for c in range(len(df)):
        try:
            user = df['user'][c]
            stat = df['stat'][c]
            ts = int(float(df['client_ts'][c]))
            reading = df['reading'][c]
            if reading.lower() == 'none':
                reading = 1.0
            else:
                reading = float(reading)
            metadata = {}
            for key in df:
                if key not in ['user', 'stat', 'client_ts', 'reading']:
                    metadata[key] = df[key][c]
            storeClientEntry(user, stat, ts, reading, metadata)
        except Exception as e:
            print(e)
            #print(df['reading'][c] == 'None')
            print(df['reading'][c] == 'None')