Esempio n. 1
0
 def test_most_recent(self):
     lldb = db.LakeLevelDB(**self.db_config)
     lldb.insert(self.example_df)
     df2 = self.example_df.copy()
     df2.index = pd.to_datetime(['2020-10-01'])
     lldb.insert(df2)
     assert lldb.most_recent().index[0] == pd.to_datetime('2020-10-01')
Esempio n. 2
0
 def test_nan_with_no_existing(self):
     lldb = db.LakeLevelDB(**self.db_config)
     df = self.example_df.copy()
     df['mendota'] = float('nan')
     lldb.insert(df)
     out_df = lldb.to_df()
     assert out_df['mendota'].size == 1
     assert pd.isnull(out_df['mendota'].iloc[0])
Esempio n. 3
0
 def test_insert_non_unique_ok_if_allowed(self):
     lldb = db.LakeLevelDB(**self.db_config)
     df = self.example_df.copy()
     lldb.insert(df)
     df['mendota'] = 10.0
     lldb.insert(df, replace=True)
     out_df = lldb.to_df()
     assert out_df['mendota'].size == 1
     assert out_df['mendota'].iloc[0] == 10.0
Esempio n. 4
0
 def test_nan_with_existing(self):
     lldb = db.LakeLevelDB(**self.db_config)
     df = self.example_df.copy()
     lldb.insert(df)
     df['mendota'] = float('nan')
     lldb.insert(df, replace=True)
     out_df = lldb.to_df()
     assert out_df['mendota'].size == 1
     assert out_df['mendota'].iloc[0] == self.example_df['mendota'].iloc[0]
Esempio n. 5
0
 def test_insert_non_unique_raises(self):
     lldb = db.LakeLevelDB(**self.db_config)
     lldb.insert(self.example_df)
     with pytest.raises(psycopg2.IntegrityError):
         lldb.insert(self.example_df, replace=False)
Esempio n. 6
0
 def test_to_df(self):
     lldb = db.LakeLevelDB(**self.db_config)
     lldb.insert(self.example_df)
     out_df = lldb.to_df()
     assert (out_df.values == self.example_df.values).all()
Esempio n. 7
0
 def test_insertion(self):
     lldb = db.LakeLevelDB(**self.db_config)
     lldb.insert(self.example_df)
     lldb._cursor.execute('SELECT * FROM levels')
     assert len(lldb._cursor.fetchall()) == 1
Esempio n. 8
0
 def test_creation(self):
     db.LakeLevelDB(**self.db_config)