From 809c3beb74db8c21aaa05ab595a7a0392d93b839 Mon Sep 17 00:00:00 2001 From: nikso Date: Mon, 20 Nov 2023 22:20:00 +0100 Subject: [PATCH] additional test cases --- test/nodejs/oml_test.js | 8 ++-- test/python/oml_test.py | 8 ++-- test/sql/oml.test | 84 ++++++++++++++++++++++++++++++----------- 3 files changed, 71 insertions(+), 29 deletions(-) diff --git a/test/nodejs/oml_test.js b/test/nodejs/oml_test.js index 480e6dd..10170b2 100644 --- a/test/nodejs/oml_test.js +++ b/test/nodejs/oml_test.js @@ -7,16 +7,16 @@ describe(`oml extension`, () => { before((done) => { db = new duckdb.Database(':memory:', {"allow_unsigned_extensions":"true"}); conn = new duckdb.Connection(db); - conn.exec(`LOAD '${process.env.QUACK_EXTENSION_BINARY_PATH}';`, function (err) { + conn.exec(`LOAD '${process.env.OML_EXTENSION_BINARY_PATH}';`, function (err) { if (err) throw err; done(); }); }); - it('oml function should return expected string', function (done) { - db.all("SELECT oml('Sam') as value;", function (err, res) { + it('oml function should return expected amount of rows', function (done) { + db.all("SELECT * from OmlGen('data/oml_testing/st_lrwan1_11.oml');", function (err, res) { if (err) throw err; - assert.deepEqual(res, [{value: "Oml Sam 🐥"}]); + assert.deepEqual(res, [{value: 67725}]); done(); }); }); diff --git a/test/python/oml_test.py b/test/python/oml_test.py index 67601e9..871a9dd 100644 --- a/test/python/oml_test.py +++ b/test/python/oml_test.py @@ -5,14 +5,14 @@ # Get a fresh connection to DuckDB with the oml extension binary loaded @pytest.fixture def duckdb_conn(): - extension_binary = os.getenv('QUACK_EXTENSION_BINARY_PATH') + extension_binary = os.getenv('OML_EXTENSION_BINARY_PATH') if (extension_binary == ''): - raise Exception('Please make sure the `QUACK_EXTENSION_BINARY_PATH` is set to run the python tests') + raise Exception('Please make sure the `OML_EXTENSION_BINARY_PATHH` is set to run the python tests') conn = duckdb.connect('', config={'allow_unsigned_extensions': 'true'}) conn.execute(f"load '{extension_binary}'") return conn def test_oml(duckdb_conn): - duckdb_conn.execute("SELECT * from OmlGen('data/oml_testing/test.oml');"); + duckdb_conn.execute("SELECT * from OmlGen('data/oml_testing/st_lrwan1_11.oml');"); res = duckdb_conn.fetchall() - assert(res[0][0] == "20"); \ No newline at end of file + assert(res[0][0] == 67725); \ No newline at end of file diff --git a/test/sql/oml.test b/test/sql/oml.test index 6f73064..4cdb6db 100644 --- a/test/sql/oml.test +++ b/test/sql/oml.test @@ -2,25 +2,41 @@ # description: test oml extension # group: [oml] -# Before we load the extension, this will fail -statement error -CALL Power_Consumption_load('data/test-small.oml'); ----- -Catalog Error: Table Function with name power_consumption_load does not exist! -Did you mean "summary"? - # Require statement will ensure this test is run with this extension loaded require oml +#################################### +### Power_Consumption_load tests ### +#################################### + # Confirm the extension works query I -SELECT * from Power_Consumption_load('data/oml_testing/test-small.oml'); +SELECT * from Power_Consumption_load('data/oml_testing/st_lrwan1_11.oml'); +---- +67725 + +# Confirm the table contains expected values +query IIIIIIII +SELECT * from Power_Consumption where node_id_seq = 10; +---- +3.542896 +1 +10 +1697457735 +506076 +0.284480 +4.871250 +0.058361 + +# Confirm the view exists with the same amount of rows +query I +SELECT count(*) from PC; ---- -7 +67725 -# Confirm the view exists and contains expected values +# Confirm the view contains expected values query IIIII -SELECT * from PC where (id == 4); +SELECT * from PC where id = 4; ---- 4 1697941200.0 @@ -28,27 +44,30 @@ SELECT * from PC where (id == 4); 4.87 0.058361 -# Confirm the view has 7 rows +# Confirm the table can be removed query I -SELECT count(*) from PC; +DROP TABLE Power_Consumption; ---- -7 + +#################### +### OmlGen tests ### +#################### # Confirm OmlGen works query I -SELECT * from OmlGen('data/oml_testing/test.oml'); +SELECT * from OmlGen('data/oml_testing/st_lrwan1_11.oml'); ---- -20 +67725 -# Confirm that OmlGen can read other types of OML as well +# Confirm that OmlGen can read other OML schema query I -SELECT * from OmlGen('data/oml_testing/test-small.oml'); +SELECT * from OmlGen('data/oml_testing/st_lrwan1_15.oml'); ---- -7 +1204 -# Confirm that OmlGen returns expected values +# Confirm that 'st_lrwan1_15' contains expected values query IIIIIII -SELECT * from control_node_measures_radio where (value == 2); +SELECT * from control_node_measures_radio where value = 2; ---- 6.921713 2 @@ -57,3 +76,26 @@ SELECT * from control_node_measures_radio where (value == 2); 909600 11 -91 + +# Confirm that 'st_lrwan1_11' contains expected values +query IIIIIIII +SELECT * from control_node_measures_consumption where value = 20; +---- +3.606484 +1 +20 +1697457735 +551237 +0.284480 +4.870000 +0.058361 + +# Confirm that both tables can be dropped +query I +DROP TABLE control_node_measures_consumption; +---- + +query I +DROP TABLE control_node_measures_radio; +---- +