Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record before schema should throw an exception #57

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions target_postgres/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,14 @@ def max_parallelism(self) -> int:
"""
# https://github.com/MeltanoLabs/target-postgres/issues/3
return 1

def _process_record_message(self, message_dict: dict) -> None:
"""Process a RECORD message.

Args:
message_dict: TODO
"""
stream_name = message_dict["stream"]
if self.mapper.stream_maps.get(stream_name) is None:
raise Exception(f"Schema message has not been sent for {stream_name}")
super()._process_record_message(message_dict)
12 changes: 8 additions & 4 deletions target_postgres/tests/test_standard_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ def test_aapl_to_postgres(postgres_config):
sync_end_to_end(tap, target)


# TODO this test should throw an exception
def test_record_before_schema(postgres_target):
file_name = "record_before_schema.singer"
singer_file_to_target(file_name, postgres_target)
with pytest.raises(Exception) as e:
file_name = "record_before_schema.singer"
singer_file_to_target(file_name, postgres_target)

assert (
str(e.value) == "Schema message has not been sent for test_record_before_schema"
)


# TODO this test should throw an exception
Expand All @@ -107,7 +111,7 @@ def test_record_missing_required_property(postgres_target):

# TODO test that data is correctly set
# see target-sqllit/tests/test_target_sqllite.py
def test_record_missing_required_property(postgres_target):
def test_camelcase(postgres_target):
file_name = "camelcase.singer"
singer_file_to_target(file_name, postgres_target)

Expand Down