def test_get_from_id(self): OSD = process.OSD(DB_FILE_NAME) id = 1 res = OSD.Get_Data_From_ID(id) self.assertEqual(inserted, res)
def test_delete_weight_data(self): OSD = process.OSD(DB_FILE_NAME) id = 1 OSD.Delete_Weight_Data(id) res = OSD.Get_Data_From_ID(id) self.assertEqual(0, len(res))
def setUp(self): OSD = process.OSD(DB_FILE_NAME) global inserted_multi inserted = [] heightlist = [random.uniform(170, 180) for i in range(5)] weightlist = [random.uniform(80, 90) for i in range(5)] for h, w in zip(heightlist, weightlist): stored = OSD.NewData(h, w) inserted.append(stored) time.sleep(0.1) inserted_multi = inserted
def test_update_weight_data(self): OSD = process.OSD(DB_FILE_NAME) id = 1 weight = 87.0 height = 172.2 OSD.Update_Weight_Data(id, height, weight) updated = OSD.Get_Data_From_ID(id) inserted[1] = height inserted[2] = weight self.assertEqual(inserted, updated)
def test_insert_newdata(self): OSD = process.OSD(DB_FILE_NAME) height = 178.5 weight = 88.0 id = 1 res = OSD.NewData(height, weight) actual = [id, height, weight] actual.append(res[-1]) self.assertEqual(res, actual) res[-1] = res[-1].strftime('%Y-%m-%d %H:%M:%S.%f') global inserted inserted = res print(actual)
def test_get_data_monthly(self): OSD = process.OSD(DB_FILE_NAME) res = OSD.Get_Monthly_Log() self.assertEqual(len(res) - 1, len(inserted_multi))