Skip to content

Commit

Permalink
Add target class init test
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Aug 23, 2022
1 parent 39af208 commit 32b1706
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions samples/sample_tap_sqlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class SQLiteTap(SQLTap):
DB_PATH_CONFIG,
th.StringType,
description="The path to your SQLite database file(s).",
required=True,
)
).to_dict()

Expand Down
1 change: 1 addition & 0 deletions samples/sample_target_sqlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class SQLiteTarget(SQLTarget):
DB_PATH_CONFIG,
th.StringType,
description="The path to your SQLite database file(s).",
required=True,
)
).to_dict()

Expand Down
33 changes: 33 additions & 0 deletions tests/core/test_target_class.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from __future__ import annotations

from contextlib import nullcontext

import pytest

from samples.sample_target_sqlite import SQLiteTarget
from singer_sdk.exceptions import ConfigValidationError


@pytest.mark.parametrize(
"config_dict,expectation,errors",
[
pytest.param(
{},
pytest.raises(ConfigValidationError, match="Config validation failed"),
["'path_to_db' is a required property"],
id="missing_path_to_db",
),
pytest.param(
{"path_to_db": "sqlite://test.db"},
nullcontext(),
[],
id="valid_config",
),
],
)
def test_config_errors(config_dict: dict, expectation, errors: list[str]):
with expectation as exc:
SQLiteTarget(config_dict, validate_config=True)

if isinstance(exc, pytest.ExceptionInfo):
assert exc.value.errors == errors

0 comments on commit 32b1706

Please sign in to comment.