-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add initial tests for helper parsing functions
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import unittest | ||
from unittest.mock import mock_open, patch | ||
from twkit import helper | ||
|
||
mocked_yaml = """ | ||
datasets: | ||
- name: 'test_dataset1' | ||
description: 'My test dataset 1' | ||
header: true | ||
workspace: 'my_organization/my_workspace' | ||
file-path: './examples/yaml/datasets/samples.csv' | ||
overwrite: True | ||
""" | ||
|
||
mocked_file = mock_open(read_data=mocked_yaml) | ||
|
||
|
||
class TestYamlParserFunctions(unittest.TestCase): | ||
@patch("builtins.open", mocked_file) | ||
def test_parse_datasets_yaml(self): | ||
result = helper.parse_all_yaml(["test_path.yaml"]) | ||
expected_block_output = [ | ||
{ | ||
"cmd_args": [ | ||
"--header", | ||
"./examples/yaml/datasets/samples.csv", | ||
"--name", | ||
"test_dataset1", | ||
"--workspace", | ||
"my_organization/my_workspace", | ||
"--description", | ||
"My test dataset 1", | ||
], | ||
"overwrite": True, | ||
} | ||
] | ||
|
||
self.assertIn("datasets", result) | ||
self.assertEqual(result["datasets"], expected_block_output) | ||
|
||
|
||
# TODO: add more tests for other functions in helper.py |