11from __tests .testing_web .context import Context
2+ from __tests .testing_web .memory_db import MemoryDb
23from instaui import ui
34import pandas as pd
45import pybi
5- from __tests .utils import Table , Select
6+ from __tests .utils import Table , Select , display , ListBox
67
78
8- def test_base (context : Context ):
9+ def test_base (context : Context , memory_db : MemoryDb ):
910 data = {"Name" : ["foo" , "foo" , "bar" ], "Age" : [18 , 19 , 20 ]}
10-
11- dataset = pybi .duckdb .from_pandas ({"df" : pd .DataFrame (data )})
11+ dataset = memory_db .from_dataframe ({"df" : pd .DataFrame (data )})
1212
1313 @context .register_page
1414 def index ():
@@ -21,10 +21,11 @@ def index():
2121 Table (context ).should_values_any_cell ("18.5" )
2222
2323
24- def test_upstream_data_view_update_affects_downstream (context : Context ):
24+ def test_upstream_data_view_update_affects_downstream (
25+ context : Context , memory_db : MemoryDb
26+ ):
2527 data = {"Name" : ["foo" , "foo" , "bar" ], "Age" : [18 , 19 , 20 ]}
26-
27- dataset = pybi .duckdb .from_pandas ({"df" : pd .DataFrame (data )})
28+ dataset = memory_db .from_dataframe ({"df" : pd .DataFrame (data )})
2829
2930 @context .register_page
3031 def index ():
@@ -47,10 +48,9 @@ def index():
4748 table .should_values_not_any_cell ("bar" )
4849
4950
50- def test_selected_multiple_columns (context : Context ):
51+ def test_selected_multiple_columns (context : Context , memory_db : MemoryDb ):
5152 data = {"Name" : ["foo" ], "Age" : [18 ], "class" : [1 ]}
52-
53- dataset = pybi .duckdb .from_pandas ({"df" : pd .DataFrame (data )})
53+ dataset = memory_db .from_dataframe ({"df" : pd .DataFrame (data )})
5454
5555 @context .register_page
5656 def index ():
@@ -65,41 +65,35 @@ def index():
6565 table .should_values_not_any_cell ("1" )
6666
6767
68- def test_computed_binding (context : Context ):
68+ def test_computed_binding (context : Context , memory_db : MemoryDb ):
6969 data = {"Name" : ["foo" , "bar" ], "Age" : [18 , 19 ]}
70-
71- dataset = pybi .duckdb .from_pandas ({"df" : pd .DataFrame (data )})
70+ dataset = memory_db .from_dataframe ({"df" : pd .DataFrame (data )})
7271
7372 @context .register_page
7473 def index ():
7574 table = dataset ["df" ]
7675 dv = pybi .data_view (f"SELECT * FROM { table } " )
7776
7877 @ui .computed (inputs = [dv ])
79- def result ( names ):
80- return str ( names )
78+ def value_r0_c0 ( source ):
79+ return source [ "values" ][ 0 ][ 0 ]
8180
82- pybi .label (result )
81+ ui .label (value_r0_c0 )
8382
8483 context .open ()
85- context .should_see ("[[' foo', 18], ['bar', 19]]" , equal_to = True )
84+ context .should_see ("foo" )
8685
8786
88- def test_selected_column_computed_binding (context : Context ):
87+ def test_selected_column_computed_binding (context : Context , memory_db : MemoryDb ):
8988 data = {"Name" : ["foo" , "bar" ]}
90-
91- dataset = pybi .duckdb .from_pandas ({"df" : pd .DataFrame (data )})
89+ dataset = memory_db .from_dataframe ({"df" : pd .DataFrame (data )})
9290
9391 @context .register_page
9492 def index ():
9593 table = dataset ["df" ]
9694 dv = pybi .data_view (f"SELECT * FROM { table } " )
9795
98- @ui .computed (inputs = [dv ["Name" ]])
99- def result (names ):
100- return str (names )
101-
102- pybi .label (result )
96+ display .list_box (dv ["Name" ])
10397
10498 context .open ()
105- context . should_see ( "[' foo', ' bar']" , equal_to = True )
99+ ListBox ( context ). should_have_text ([ " foo" , " bar" ] )
0 commit comments