def test_histogram_code_export(global_var): tbl = lux.LuxSQLTable() tbl.set_SQL_table("cars") vis = Vis([lux.Clause("horsepower")], tbl) SQLExecutor.execute([vis], tbl) code = vis.to_code("python") try: exec(code, globals()) create_chart_data(tbl, vis) except: assert False
def test_color_barchart_code_export(global_var): tbl = lux.LuxSQLTable() tbl.set_SQL_table("cars") vis = Vis([lux.Clause("origin"), lux.Clause("cylinders")], tbl) SQLExecutor.execute([vis], tbl) code = vis.to_code("python") try: exec(code, globals()) create_chart_data(tbl, vis) except: assert False
def test_lazy_execution(): tbl = lux.LuxSQLTable() tbl.set_SQL_table("cars") intent = [ lux.Clause(attribute="horsepower", aggregation="mean"), lux.Clause(attribute="origin"), ] vis = Vis(intent) # Check data field in vis is empty before calling executor assert vis.data is None SQLExecutor.execute([vis], tbl) assert type(vis.data) == lux.core.frame.LuxDataFrame
def test_lazy_execution(): connection = psycopg2.connect( "host=localhost dbname=postgres user=postgres password=lux") sql_df = lux.LuxSQLTable() lux.config.set_SQL_connection(connection) sql_df.set_SQL_table("car") intent = [ lux.Clause(attribute="Horsepower", aggregation="mean"), lux.Clause(attribute="Origin"), ] vis = Vis(intent) # Check data field in vis is empty before calling executor assert vis.data is None SQLExecutor.execute([vis], sql_df) assert type(vis.data) == lux.core.frame.LuxDataFrame