Skip to content

Commit

Permalink
test: add initial tests for helper parsing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ejseqera committed Oct 6, 2023
1 parent fed7bee commit 5deec1f
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/unit/test_helper.py
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

0 comments on commit 5deec1f

Please sign in to comment.