From 0ec59f2acd883f71499dc28c2fbd51392c2c19ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Tue, 16 Jul 2024 18:14:24 -0600 Subject: [PATCH] Move tests --- tests/_singerlib/_encoding/test_msgspec.py | 41 ++++++++++++++ tests/core/test_io.py | 62 ---------------------- 2 files changed, 41 insertions(+), 62 deletions(-) create mode 100644 tests/_singerlib/_encoding/test_msgspec.py diff --git a/tests/_singerlib/_encoding/test_msgspec.py b/tests/_singerlib/_encoding/test_msgspec.py new file mode 100644 index 0000000000..f5dc0a022b --- /dev/null +++ b/tests/_singerlib/_encoding/test_msgspec.py @@ -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 diff --git a/tests/core/test_io.py b/tests/core/test_io.py index 5d27a86ef3..a2b675de24 100644 --- a/tests/core/test_io.py +++ b/tests/core/test_io.py @@ -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 @@ -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", [