-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
File-based CDK: allow user to provided column names (#29868)
- Loading branch information
Showing
6 changed files
with
181 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
airbyte-cdk/python/unit_tests/sources/file_based/config/test_csv_format.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import unittest | ||
|
||
import pytest | ||
from airbyte_cdk.sources.file_based.config.csv_format import CsvHeaderAutogenerated, CsvHeaderFromCsv, CsvHeaderUserProvided | ||
from pydantic import ValidationError | ||
|
||
|
||
class CsvHeaderDefinitionTest(unittest.TestCase): | ||
def test_given_user_provided_and_not_column_names_provided_then_raise_exception(self) -> None: | ||
with pytest.raises(ValidationError): | ||
CsvHeaderUserProvided(column_names=[]) | ||
|
||
def test_given_user_provided_and_column_names_then_config_is_valid(self) -> None: | ||
# no error means that this test succeeds | ||
CsvHeaderUserProvided(column_names=["1", "2", "3"]) | ||
|
||
def test_given_user_provided_then_csv_does_not_have_header_row(self) -> None: | ||
assert not CsvHeaderUserProvided(column_names=["1", "2", "3"]).has_header_row() | ||
|
||
def test_given_autogenerated_then_csv_does_not_have_header_row(self) -> None: | ||
assert not CsvHeaderAutogenerated().has_header_row() | ||
|
||
def test_given_from_csv_then_csv_has_header_row(self) -> None: | ||
assert CsvHeaderFromCsv().has_header_row() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters