Skip to content

Commit

Permalink
additional test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nikso-itu committed Nov 20, 2023
1 parent ed4b0a8 commit 809c3be
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 29 deletions.
8 changes: 4 additions & 4 deletions test/nodejs/oml_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand Down
8 changes: 4 additions & 4 deletions test/python/oml_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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");
assert(res[0][0] == 67725);
84 changes: 63 additions & 21 deletions test/sql/oml.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,72 @@
# 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
0.283869
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
Expand All @@ -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;
----

0 comments on commit 809c3be

Please sign in to comment.