@@ -3,7 +3,7 @@ library(DBI)
33library(RSQLite )
44library(querychat )
55
6- test_that(" create_data_source .data.frame creates proper S3 object" , {
6+ test_that(" as_querychat_data_source .data.frame creates proper S3 object" , {
77 # Create a simple data frame
88 test_df <- data.frame (
99 id = 1 : 5 ,
@@ -13,7 +13,7 @@ test_that("create_data_source.data.frame creates proper S3 object", {
1313 )
1414
1515 # Test with explicit table name
16- source <- create_data_source (test_df , table_name = " test_table" )
16+ source <- as_querychat_data_source (test_df , table_name = " test_table" )
1717 withr :: defer(cleanup_source(source ))
1818
1919 expect_s3_class(source , " data_frame_source" )
@@ -22,7 +22,7 @@ test_that("create_data_source.data.frame creates proper S3 object", {
2222 expect_true(inherits(source $ conn , " DBIConnection" ))
2323})
2424
25- test_that(" create_data_source .DBIConnection creates proper S3 object" , {
25+ test_that(" as_querychat_data_source .DBIConnection creates proper S3 object" , {
2626 # Create temporary SQLite database
2727 temp_db <- withr :: local_tempfile(fileext = " .db" )
2828 conn <- dbConnect(RSQLite :: SQLite(), temp_db )
@@ -39,7 +39,7 @@ test_that("create_data_source.DBIConnection creates proper S3 object", {
3939 dbWriteTable(conn , " users" , test_data , overwrite = TRUE )
4040
4141 # Test DBI source creation
42- db_source <- create_data_source (conn , " users" )
42+ db_source <- as_querychat_data_source (conn , " users" )
4343 expect_s3_class(db_source , " dbi_source" )
4444 expect_s3_class(db_source , " querychat_data_source" )
4545 expect_equal(db_source $ table_name , " users" )
@@ -54,7 +54,7 @@ test_that("get_schema methods return proper schema", {
5454 stringsAsFactors = FALSE
5555 )
5656
57- df_source <- create_data_source (test_df , table_name = " test_table" )
57+ df_source <- as_querychat_data_source (test_df , table_name = " test_table" )
5858 withr :: defer(cleanup_source(df_source ))
5959
6060 schema <- get_schema(df_source )
@@ -75,7 +75,7 @@ test_that("get_schema methods return proper schema", {
7575
7676 dbWriteTable(conn , " test_table" , test_df , overwrite = TRUE )
7777
78- dbi_source <- create_data_source (conn , " test_table" )
78+ dbi_source <- as_querychat_data_source (conn , " test_table" )
7979 schema <- get_schema(dbi_source )
8080 expect_type(schema , " character" )
8181 expect_match(schema , " Table: `test_table`" )
@@ -94,7 +94,7 @@ test_that("execute_query works for both source types", {
9494 stringsAsFactors = FALSE
9595 )
9696
97- df_source <- create_data_source (test_df , table_name = " test_table" )
97+ df_source <- as_querychat_data_source (test_df , table_name = " test_table" )
9898 withr :: defer(cleanup_source(df_source ))
9999 result <- execute_query(
100100 df_source ,
@@ -109,7 +109,7 @@ test_that("execute_query works for both source types", {
109109 withr :: defer(dbDisconnect(conn ))
110110 dbWriteTable(conn , " test_table" , test_df , overwrite = TRUE )
111111
112- dbi_source <- create_data_source (conn , " test_table" )
112+ dbi_source <- as_querychat_data_source (conn , " test_table" )
113113 result <- execute_query(
114114 dbi_source ,
115115 " SELECT * FROM test_table WHERE value > 25"
@@ -126,7 +126,7 @@ test_that("execute_query works with empty/null queries", {
126126 stringsAsFactors = FALSE
127127 )
128128
129- df_source <- create_data_source (test_df , table_name = " test_table" )
129+ df_source <- as_querychat_data_source (test_df , table_name = " test_table" )
130130 withr :: defer(cleanup_source(df_source ))
131131
132132 # Test with NULL query
@@ -148,7 +148,7 @@ test_that("execute_query works with empty/null queries", {
148148
149149 dbWriteTable(conn , " test_table" , test_df , overwrite = TRUE )
150150
151- dbi_source <- create_data_source (conn , " test_table" )
151+ dbi_source <- as_querychat_data_source (conn , " test_table" )
152152
153153 # Test with NULL query
154154 result_null <- execute_query(dbi_source , NULL )
@@ -173,7 +173,7 @@ test_that("get_schema correctly reports min/max values for numeric columns", {
173173 stringsAsFactors = FALSE
174174 )
175175
176- df_source <- create_data_source (test_df , table_name = " test_metrics" )
176+ df_source <- as_querychat_data_source (test_df , table_name = " test_metrics" )
177177 withr :: defer(cleanup_source(df_source ))
178178 schema <- get_schema(df_source )
179179
@@ -191,7 +191,7 @@ test_that("create_system_prompt generates appropriate system prompt", {
191191 stringsAsFactors = FALSE
192192 )
193193
194- df_source <- create_data_source (test_df , table_name = " test_table" )
194+ df_source <- as_querychat_data_source (test_df , table_name = " test_table" )
195195 withr :: defer(cleanup_source(df_source ))
196196
197197 prompt <- create_system_prompt(
@@ -220,7 +220,7 @@ test_that("QueryChat$new() automatically handles data.frame inputs", {
220220 expect_s3_class(qc $ data_source , " data_frame_source" )
221221
222222 # Should work with proper data source too
223- df_source <- create_data_source (test_df , table_name = " test_table" )
223+ df_source <- as_querychat_data_source (test_df , table_name = " test_table" )
224224 withr :: defer(cleanup_source(df_source ))
225225
226226 qc2 <- QueryChat $ new(
@@ -240,7 +240,7 @@ test_that("QueryChat$new() works with both source types", {
240240 )
241241
242242 # Create data source and test with QueryChat$new()
243- df_source <- create_data_source (test_df , table_name = " test_source" )
243+ df_source <- as_querychat_data_source (test_df , table_name = " test_source" )
244244 withr :: defer(cleanup_source(df_source ))
245245
246246 qc <- QueryChat $ new(
@@ -259,7 +259,7 @@ test_that("QueryChat$new() works with both source types", {
259259
260260 dbWriteTable(conn , " test_table" , test_df , overwrite = TRUE )
261261
262- dbi_source <- create_data_source (conn , " test_table" )
262+ dbi_source <- as_querychat_data_source (conn , " test_table" )
263263 qc2 <- QueryChat $ new(
264264 data_source = dbi_source ,
265265 table_name = " test_table" ,
0 commit comments