Skip to content

Commit

Permalink
Move tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Jul 17, 2024
1 parent cd61c69 commit 0ec59f2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 62 deletions.
41 changes: 41 additions & 0 deletions tests/_singerlib/_encoding/test_msgspec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from __future__ import annotations # noqa: INP001

import pytest

from singer_sdk._singerlib._encoding.msgspec import dec_hook, enc_hook


@pytest.mark.parametrize(
"test_type,test_value,expected_value,expected_type",
[
pytest.param(
int,
1,
"1",
str,
id="int-to-str",
),
],
)
def test_dec_hook(test_type, test_value, expected_value, expected_type):
returned = dec_hook(type=test_type, obj=test_value)
returned_type = type(returned)

assert returned == expected_value
assert returned_type == expected_type


@pytest.mark.parametrize(
"test_value,expected_value",
[
pytest.param(
1,
"1",
id="int-to-str",
),
],
)
def test_enc_hook(test_value, expected_value):
returned = enc_hook(obj=test_value)

assert returned == expected_value
62 changes: 0 additions & 62 deletions tests/core/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,17 @@
import io
import itertools
import json
import sys
import typing as t
from contextlib import nullcontext, redirect_stdout
from textwrap import dedent

import pytest

from singer_sdk._singerlib import RecordMessage
from singer_sdk._singerlib._encoding.msgspec import dec_hook, enc_hook
from singer_sdk._singerlib.exceptions import InvalidInputLine
from singer_sdk.io_base import SingerReader, SingerWriter


class DummyReader(SingerReader):
returned_file_input: t.IO = None

def _process_lines(self, file_input: t.IO) -> t.Counter[str]:
self.returned_file_input = file_input

def _process_activate_version_message(self, message_dict: dict) -> None:
pass

Expand All @@ -41,60 +33,6 @@ def _process_state_message(self, message_dict: dict) -> None:
pass


@pytest.mark.parametrize(
"test_type,test_value,expected_value,expected_type",
[
pytest.param(
int,
1,
"1",
str,
id="int-to-str",
),
],
)
def test_dec_hook(test_type, test_value, expected_value, expected_type):
returned = dec_hook(type=test_type, obj=test_value)
returned_type = type(returned)

assert returned == expected_value
assert returned_type == expected_type


@pytest.mark.parametrize(
"test_value,expected_value",
[
pytest.param(
1,
"1",
id="int-to-str",
),
],
)
def test_enc_hook(test_value, expected_value):
returned = enc_hook(obj=test_value)

assert returned == expected_value


@pytest.mark.parametrize(
"test_value,expected_value",
[
pytest.param(
None,
sys.stdin.buffer,
id="file_input_is_none",
),
],
)
def test_listen_file_input(test_value, expected_value):
reader = DummyReader()

reader.listen(test_value)

assert reader.returned_file_input is expected_value


@pytest.mark.parametrize(
"line,expected,exception",
[
Expand Down

0 comments on commit 0ec59f2

Please sign in to comment.