-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
populate notebook with code and markdown
- Loading branch information
1 parent
aa859ea
commit 24fae57
Showing
6 changed files
with
70 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -290,4 +290,4 @@ export const populateNotebook = async (notebookContent: JupyterCellProps[], note | |
} | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...terlab-extension/vdk_jupyterlab_extension/tests/test_transform_job_directory_processor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright 2021-2023 VMware, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
import shutil | ||
import tempfile | ||
import unittest | ||
|
||
from vdk_jupyterlab_extension.transform_job import TransformJobDirectoryProcessor | ||
|
||
|
||
class TestTransformJobDirectoryProcessor(unittest.TestCase): | ||
def setUp(self): | ||
self.temp_dir = tempfile.mkdtemp() | ||
self.sql_content = "SELECT * FROM table" | ||
self.py_content_run = """ | ||
def run(job_input: IJobInput): | ||
print("Hello, World!") | ||
""" | ||
self.py_content_without_run = """ | ||
def hello(): | ||
print("Hello, World!") | ||
""" | ||
|
||
with open(os.path.join(self.temp_dir, "test.sql"), "w") as f: | ||
f.write(self.sql_content) | ||
with open(os.path.join(self.temp_dir, "test_run.py"), "w") as f: | ||
f.write(self.py_content_run) | ||
with open(os.path.join(self.temp_dir, "test_without_run.py"), "w") as f: | ||
f.write(self.py_content_without_run) | ||
with open(os.path.join(self.temp_dir, "config.ini"), "w") as f: | ||
pass | ||
|
||
self.processor = TransformJobDirectoryProcessor(self.temp_dir) | ||
|
||
def tearDown(self): | ||
shutil.rmtree(self.temp_dir) | ||
|
||
def test_process_files(self): | ||
self.processor.process_files() | ||
expected_code_structure = [ | ||
f'job_input.execute_query("""{self.sql_content}""")', | ||
self.py_content_run, | ||
] | ||
self.assertEqual(self.processor.get_code_structure(), expected_code_structure) | ||
self.assertFalse(os.path.exists(os.path.join(self.temp_dir, "test.sql"))) | ||
self.assertFalse(os.path.exists(os.path.join(self.temp_dir, "test_run.py"))) | ||
self.assertTrue( | ||
os.path.exists(os.path.join(self.temp_dir, "test_without_run.py")) | ||
) | ||
self.assertTrue(os.path.exists(os.path.join(self.temp_dir, "config.ini"))) | ||
|
||
expected_removed_files = ["test.sql", "test_run.py"] | ||
self.assertEqual(self.processor.get_removed_files(), expected_removed_files) | ||
|
||
def test_get_code_structure(self): | ||
self.processor.process_files() | ||
expected_code_structure = [ | ||
f'job_input.execute_query("""{self.sql_content}""")', | ||
self.py_content_run, | ||
] | ||
self.assertEqual(self.processor.get_code_structure(), expected_code_structure) | ||
|
||
def test_get_removed_files(self): | ||
self.processor.process_files() | ||
expected_removed_files = ["test.sql", "test_run.py"] | ||
self.assertEqual(self.processor.get_removed_files(), expected_removed_files) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters