-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Test] Add test cases for RecceConfig
Signed-off-by: Kent Huang <[email protected]>
- Loading branch information
1 parent
996aec1
commit 39c44b7
Showing
2 changed files
with
48 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,11 @@ | ||
# Preset Checks | ||
# Please see https://datarecce.io/docs/features/preset-checks/ | ||
checks: | ||
- name: Row count diff | ||
description: Check the row count diff for all table models. | ||
type: row_count_diff | ||
params: | ||
select: state:modified,config.materialized:table | ||
- name: Schema diff | ||
description: Check the schema diff for all nodes. | ||
type: schema_diff |
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,37 @@ | ||
import os.path | ||
from unittest import TestCase | ||
from unittest.mock import patch | ||
|
||
from recce.config import RecceConfig | ||
from recce.util import SingletonMeta | ||
|
||
test_root_path = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
class RecceConfigTestCase(TestCase): | ||
def setUp(self): | ||
self.recce_config_path = os.path.join(test_root_path, 'data', 'config', 'recce.yml') | ||
pass | ||
|
||
def tearDown(self): | ||
# Reset the SingletonMeta instances due to RecceConfig is a singleton | ||
SingletonMeta._instances = {} | ||
|
||
def test_load_recce_config(self): | ||
config = RecceConfig(self.recce_config_path) | ||
|
||
# Test data contains 2 checks | ||
preset_checks = config.config.get('checks') | ||
self.assertIsNotNone(preset_checks) | ||
self.assertIsInstance(preset_checks, list) | ||
self.assertEqual(len(preset_checks), 2) | ||
|
||
@patch('recce.config.RecceConfig.save') | ||
def test_recce_config_not_found(self, mock_save): | ||
default_config = RecceConfig('NOT_EXISTING_FILE') | ||
assert mock_save.called is True | ||
# Default config should be generated | ||
preset_checks = default_config.config.get('checks') | ||
self.assertIsNotNone(default_config.config) | ||
self.assertIsInstance(preset_checks, list) | ||
self.assertEqual(len(preset_checks), 2) |