Skip to content

Commit dece67e

Browse files
committed
tests
1 parent cd67469 commit dece67e

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from cube import TemplateContext
2+
import os
3+
from utils import answer_to_main_question
4+
5+
6+
template = TemplateContext()
7+
8+
value_or_none = os.getenv('MY_ENV_VAR')
9+
template.add_variable('value_or_none', value_or_none)
10+
11+
value_or_default = os.getenv('MY_OTHER_ENV_VAR', 'my_default_value')
12+
template.add_variable('value_or_default', value_or_default)
13+
14+
template.add_variable('answer_to_main_question', answer_to_main_question())

packages/cubejs-backend-native/test/python.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ async function loadConfigurationFile(fileName: string) {
2828
return config;
2929
}
3030

31+
const nativeInstance = new native.NativeInstance();
32+
33+
suite('Python Models', () => {
34+
test('models import', async () => {
35+
const fullFileName = path.join(process.cwd(), 'test', 'globals.py');
36+
const content = await fs.readFile(fullFileName, 'utf8');
37+
38+
// Just checking it won't fail
39+
await nativeInstance.loadPythonContext(fullFileName, content);
40+
});
41+
});
42+
3143
suite('Python Config', () => {
3244
let config: PyConfiguration;
3345

packages/cubejs-backend-native/test/utils.py

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
# Simple test function
44
def test_function(query: dict) -> dict:
55
return query
6+
7+
def answer_to_main_question() -> str:
8+
return "42"

0 commit comments

Comments
 (0)