Skip to content

Commit

Permalink
add kg table test
Browse files Browse the repository at this point in the history
  • Loading branch information
briangu committed Dec 23, 2023
1 parent 8ea71b7 commit 9d7e82c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions tests/kgtests/db/mkdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import numpy as np
import pandas as pd


def mkdf(x):
return pd.DataFrame({'col1': np.arange(x)})
8 changes: 8 additions & 0 deletions tests/kgtests/db/test_table_from_df.kg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.py("klongpy.db")
.py("tests/kgtests/db/mkdf.py")
df::mkdf(10)
T::.table(df)

t("#T=10";#T;10)
t(".schema(T)=[""col1""]";.schema(T);["col1"])
t("T?""col1""=!10";T?"col1";!10)
2 changes: 0 additions & 2 deletions tests/test_sys_fn_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def test_table_from_a_df_with_single_row_and_two_columns(self):
klong['df'] = df
klong('.py("klongpy.db")')
klong('T::.table(df)')
klong('.p(T)')
r = klong('#T')
self.assertEqual(r, 1)
r = klong('.schema(T)')
Expand All @@ -78,7 +77,6 @@ def test_table_from_a_df_with_one_column_many_rows(self):
klong['df'] = df
klong('.py("klongpy.db")')
klong('T::.table(df)')
klong('.p(T)')
r = klong('#T')
self.assertEqual(r, 10)
r = klong('.schema(T)')
Expand Down

0 comments on commit 9d7e82c

Please sign in to comment.