Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update test to utilize SingerWriter class
Browse files Browse the repository at this point in the history
BuzzCutNorman committed Nov 16, 2023
1 parent 6f2c39a commit af90f6c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/_singerlib/test_messages.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
from pytz import timezone

import singer_sdk._singerlib as singer
from singer_sdk._singerlib.messages import format_message
from singer_sdk.io_base import SingerWriter

UTC = datetime.timezone.utc

@@ -19,24 +19,26 @@ def test_exclude_null_dict():


def test_format_message():
singerwriter = SingerWriter()
message = singer.RecordMessage(
stream="test",
record={"id": 1, "name": "test"},
)
assert format_message(message) == (
assert singerwriter.format_message(message) == (
b'{"type":"RECORD","stream":"test","record":{"id":1,"name":"test"}}\n'
)


def test_write_message():
singerwriter = SingerWriter()
message = singer.RecordMessage(
stream="test",
record={"id": 1, "name": "test"},
)
stdout_buf = io.StringIO()
stdout_buf.buffer = io.BufferedRandom(raw=io.BytesIO())
with redirect_stdout(stdout_buf) as out:
singer.write_message(message)
singerwriter.write_message(message)
out.buffer.seek(0)
assert out.buffer.read() == (
b'{"type":"RECORD","stream":"test","record":{"id":1,"name":"test"}}\n'

0 comments on commit af90f6c

Please sign in to comment.