Skip to content

Commit

Permalink
Test SQL target capabilities info
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Dec 20, 2023
1 parent 154ca15 commit 27caeb2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Empty file added tests/core/targets/__init__.py
Empty file.
50 changes: 50 additions & 0 deletions tests/core/targets/test_target_sql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from __future__ import annotations

import typing as t

import pytest

from singer_sdk.helpers.capabilities import CapabilitiesEnum, TargetCapabilities
from singer_sdk.target_base import SQLTarget


class SQLTargetMock(SQLTarget):
name = "sql-target-mock"

def __init_subclass__(
cls,
*,
capabilities: t.Iterable[CapabilitiesEnum],
**kwargs: t.Any,
):
super().__init_subclass__(**kwargs)
cls.capabilities = [*capabilities]
cls.config_jsonschema = {"properties": {}}


@pytest.mark.parametrize(
"capabilities,expected_settings",
[
pytest.param([], set(), id="no capabilities"),
pytest.param(
[TargetCapabilities.TARGET_SCHEMA],
{"default_target_schema"},
id="default schema",
),
pytest.param(
[TargetCapabilities.HARD_DELETE],
{"hard_delete"},
id="hard delete",
),
],
)
def test_target_about_info(
capabilities: list[CapabilitiesEnum],
expected_settings: set[str],
):
class MyTarget(SQLTargetMock, capabilities=capabilities):
pass

about = MyTarget._get_about_info()
default_settings = {"add_record_metadata", "load_method"}
assert set(about.settings["properties"]) == expected_settings | default_settings

0 comments on commit 27caeb2

Please # to comment.