Skip to content

Commit eb0f643

Browse files
authored
addl cleanup
1 parent c26345e commit eb0f643

File tree

11 files changed

+36
-126
lines changed

11 files changed

+36
-126
lines changed

airbyte_cdk/connector_builder/connector_builder_handler.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737

3838
@dataclass
3939
class TestLimits:
40-
__test__: ClassVar[bool] = (
41-
False # Prevent pytest from treating this as a test case, despite its name
42-
)
40+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
4341

4442
max_records: int = field(default=DEFAULT_MAXIMUM_RECORDS)
4543
max_pages_per_slice: int = field(default=DEFAULT_MAXIMUM_NUMBER_OF_PAGES_PER_SLICE)

airbyte_cdk/connector_builder/test_reader/reader.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ class TestReader:
6666
6767
"""
6868

69-
__test__: ClassVar[bool] = (
70-
False # Prevent pytest from treating this as a test case, despite its name
71-
)
69+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
7270

7371
logger = logging.getLogger("airbyte.connector-builder")
7472

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ filterwarnings =
88
markers =
99
slow: mark tests as slow
1010
asyncio: mark test as asyncio
11+
requires_creds: mark test as requiring credentials

unit_tests/connector_builder/test_connector_builder_handler.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -983,11 +983,7 @@ def test_create_source() -> None:
983983
max_records = 3
984984
max_pages_per_slice = 2
985985
max_slices = 1
986-
limits = TestLimits(
987-
max_records=max_records,
988-
max_pages_per_slice=max_pages_per_slice,
989-
max_slices=max_slices,
990-
)
986+
limits = TestLimits(max_records, max_pages_per_slice, max_slices)
991987

992988
config = {"__injected_declarative_manifest": MANIFEST}
993989

@@ -1069,11 +1065,7 @@ def test_read_source(mock_http_stream):
10691065
max_records = 100
10701066
max_pages_per_slice = 2
10711067
max_slices = 3
1072-
limits = TestLimits(
1073-
max_records=max_records,
1074-
max_pages_per_slice=max_pages_per_slice,
1075-
max_slices=max_slices,
1076-
)
1068+
limits = TestLimits(max_records, max_pages_per_slice, max_slices)
10771069

10781070
catalog = ConfiguredAirbyteCatalog(
10791071
streams=[
@@ -1120,11 +1112,7 @@ def test_read_source_single_page_single_slice(mock_http_stream):
11201112
max_records = 100
11211113
max_pages_per_slice = 1
11221114
max_slices = 1
1123-
limits = TestLimits(
1124-
max_records=max_records,
1125-
max_pages_per_slice=max_pages_per_slice,
1126-
max_slices=max_slices,
1127-
)
1115+
limits = TestLimits(max_records, max_pages_per_slice, max_slices)
11281116

11291117
catalog = ConfiguredAirbyteCatalog(
11301118
streams=[
@@ -1208,11 +1196,7 @@ def test_handle_read_external_requests(deployment_mode, url_base, expected_error
12081196
endpoints when running on Cloud or OSS deployments
12091197
"""
12101198

1211-
limits = TestLimits(
1212-
max_records=100,
1213-
max_pages_per_slice=1,
1214-
max_slices=1,
1215-
)
1199+
limits = TestLimits(max_records=100, max_pages_per_slice=1, max_slices=1)
12161200

12171201
catalog = ConfiguredAirbyteCatalog(
12181202
streams=[
@@ -1298,11 +1282,7 @@ def test_handle_read_external_oauth_request(deployment_mode, token_url, expected
12981282
endpoints when running on Cloud or OSS deployments
12991283
"""
13001284

1301-
limits = TestLimits(
1302-
max_records=100,
1303-
max_pages_per_slice=1,
1304-
max_slices=1,
1305-
)
1285+
limits = TestLimits(max_records=100, max_pages_per_slice=1, max_slices=1)
13061286

13071287
catalog = ConfiguredAirbyteCatalog(
13081288
streams=[

unit_tests/connector_builder/test_message_grouper.py

Lines changed: 17 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,7 @@ def test_get_grouped_messages(mock_entrypoint_read: Mock) -> None:
203203
),
204204
)
205205

206-
connector_builder_handler = TestReader(
207-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
208-
max_slices=MAX_SLICES,
209-
)
206+
connector_builder_handler = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
210207
actual_response: StreamRead = connector_builder_handler.run_test_read(
211208
source=mock_source,
212209
config=CONFIG,
@@ -290,10 +287,7 @@ def test_get_grouped_messages_with_logs(mock_entrypoint_read: Mock) -> None:
290287
),
291288
)
292289

293-
connector_builder_handler = TestReader(
294-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
295-
max_slices=MAX_SLICES,
296-
)
290+
connector_builder_handler = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
297291

298292
actual_response: StreamRead = connector_builder_handler.run_test_read(
299293
source=mock_source,
@@ -346,11 +340,7 @@ def test_get_grouped_messages_record_limit(
346340
n_records = 2
347341
record_limit = min(request_record_limit, max_record_limit)
348342

349-
api = TestReader(
350-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
351-
max_slices=MAX_SLICES,
352-
max_record_limit=max_record_limit,
353-
)
343+
api = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES, max_record_limit=max_record_limit)
354344
# this is the call we expect to raise an exception
355345
if should_fail:
356346
with pytest.raises(ValueError):
@@ -414,11 +404,7 @@ def test_get_grouped_messages_default_record_limit(
414404
)
415405
n_records = 2
416406

417-
api = TestReader(
418-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
419-
max_slices=MAX_SLICES,
420-
max_record_limit=max_record_limit,
421-
)
407+
api = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES, max_record_limit=max_record_limit)
422408
actual_response: StreamRead = api.run_test_read(
423409
source=mock_source,
424410
config=CONFIG,
@@ -457,10 +443,7 @@ def test_get_grouped_messages_limit_0(mock_entrypoint_read: Mock) -> None:
457443
]
458444
),
459445
)
460-
api = TestReader(
461-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
462-
max_slices=MAX_SLICES,
463-
)
446+
api = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
464447

465448
with pytest.raises(ValueError):
466449
api.run_test_read(
@@ -518,10 +501,7 @@ def test_get_grouped_messages_no_records(mock_entrypoint_read: Mock) -> None:
518501
),
519502
)
520503

521-
message_grouper = TestReader(
522-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
523-
max_slices=MAX_SLICES,
524-
)
504+
message_grouper = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
525505

526506
actual_response: StreamRead = message_grouper.run_test_read(
527507
source=mock_source,
@@ -634,10 +614,7 @@ def test_get_grouped_messages_with_many_slices(mock_entrypoint_read: Mock) -> No
634614
),
635615
)
636616

637-
connector_builder_handler = TestReader(
638-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
639-
max_slices=MAX_SLICES,
640-
)
617+
connector_builder_handler = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
641618

642619
stream_read: StreamRead = connector_builder_handler.run_test_read(
643620
source=mock_source,
@@ -681,10 +658,7 @@ def test_get_grouped_messages_given_maximum_number_of_slices_then_test_read_limi
681658
),
682659
)
683660

684-
api = TestReader(
685-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
686-
max_slices=MAX_SLICES,
687-
)
661+
api = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
688662

689663
stream_read: StreamRead = api.run_test_read(
690664
source=mock_source,
@@ -712,10 +686,7 @@ def test_get_grouped_messages_given_maximum_number_of_pages_then_test_read_limit
712686
),
713687
)
714688

715-
api = TestReader(
716-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
717-
max_slices=MAX_SLICES,
718-
)
689+
api = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
719690

720691
stream_read: StreamRead = api.run_test_read(
721692
source=mock_source,
@@ -734,10 +705,7 @@ def test_read_stream_returns_error_if_stream_does_not_exist() -> None:
734705

735706
full_config: Mapping[str, Any] = {**CONFIG, **{"__injected_declarative_manifest": MANIFEST}}
736707

737-
message_grouper = TestReader(
738-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
739-
max_slices=MAX_SLICES,
740-
)
708+
message_grouper = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
741709
actual_response = message_grouper.run_test_read(
742710
source=mock_source,
743711
config=full_config,
@@ -762,10 +730,7 @@ def test_given_control_message_then_stream_read_has_config_update(
762730
+ [connector_configuration_control_message(1, updated_config)]
763731
),
764732
)
765-
connector_builder_handler = TestReader(
766-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
767-
max_slices=MAX_SLICES,
768-
)
733+
connector_builder_handler = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
769734
stream_read: StreamRead = connector_builder_handler.run_test_read(
770735
source=mock_source,
771736
config=CONFIG,
@@ -795,10 +760,7 @@ def test_given_multiple_control_messages_then_stream_read_has_latest_based_on_em
795760
]
796761
),
797762
)
798-
connector_builder_handler = TestReader(
799-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
800-
max_slices=MAX_SLICES,
801-
)
763+
connector_builder_handler = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
802764
stream_read: StreamRead = connector_builder_handler.run_test_read(
803765
source=mock_source,
804766
config=CONFIG,
@@ -826,10 +788,7 @@ def test_given_multiple_control_messages_with_same_timestamp_then_stream_read_ha
826788
]
827789
),
828790
)
829-
connector_builder_handler = TestReader(
830-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
831-
max_slices=MAX_SLICES,
832-
)
791+
connector_builder_handler = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
833792
stream_read: StreamRead = connector_builder_handler.run_test_read(
834793
source=mock_source,
835794
config=CONFIG,
@@ -846,10 +805,7 @@ def test_given_auxiliary_requests_then_return_auxiliary_request(mock_entrypoint_
846805
mock_entrypoint_read,
847806
iter(any_request_and_response_with_a_record() + [auxiliary_request_log_message()]),
848807
)
849-
connector_builder_handler = TestReader(
850-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
851-
max_slices=MAX_SLICES,
852-
)
808+
connector_builder_handler = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
853809
stream_read: StreamRead = connector_builder_handler.run_test_read(
854810
source=mock_source,
855811
config=CONFIG,
@@ -863,10 +819,7 @@ def test_given_auxiliary_requests_then_return_auxiliary_request(mock_entrypoint_
863819
@patch("airbyte_cdk.connector_builder.test_reader.reader.AirbyteEntrypoint.read")
864820
def test_given_no_slices_then_return_empty_slices(mock_entrypoint_read: Mock) -> None:
865821
mock_source = make_mock_source(mock_entrypoint_read, iter([auxiliary_request_log_message()]))
866-
connector_builder_handler = TestReader(
867-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
868-
max_slices=MAX_SLICES,
869-
)
822+
connector_builder_handler = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
870823
stream_read: StreamRead = connector_builder_handler.run_test_read(
871824
source=mock_source,
872825
config=CONFIG,
@@ -892,10 +845,7 @@ def test_given_pk_then_ensure_pk_is_pass_to_schema_inferrence(mock_entrypoint_re
892845
mock_source.streams.return_value = [Mock()]
893846
mock_source.streams.return_value[0].primary_key = [["id"]]
894847
mock_source.streams.return_value[0].cursor_field = _NO_CURSOR_FIELD
895-
connector_builder_handler = TestReader(
896-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
897-
max_slices=MAX_SLICES,
898-
)
848+
connector_builder_handler = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
899849

900850
stream_read: StreamRead = connector_builder_handler.run_test_read(
901851
source=mock_source,
@@ -924,10 +874,7 @@ def test_given_cursor_field_then_ensure_cursor_field_is_pass_to_schema_inferrenc
924874
mock_source.streams.return_value = [Mock()]
925875
mock_source.streams.return_value[0].primary_key = _NO_PK
926876
mock_source.streams.return_value[0].cursor_field = ["date"]
927-
connector_builder_handler = TestReader(
928-
max_pages_per_slice=MAX_PAGES_PER_SLICE,
929-
max_slices=MAX_SLICES,
930-
)
877+
connector_builder_handler = TestReader(MAX_PAGES_PER_SLICE, MAX_SLICES)
931878

932879
stream_read: StreamRead = connector_builder_handler.run_test_read(
933880
source=mock_source,

unit_tests/sources/declarative/decoders/test_composite_decoder.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,7 @@ def test_composite_raw_decoder_csv_parser_values(requests_mock, encoding: str, d
259259

260260

261261
class TestServer(BaseHTTPRequestHandler):
262-
__test__: ClassVar[bool] = (
263-
False # Prevent pytest from thinking that this is a test class, despite the name
264-
)
262+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
265263

266264
def do_GET(self) -> None:
267265
self.send_response(200)

unit_tests/sources/declarative/parsers/testing_components.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ class TestingSomeComponent(DefaultErrorHandler):
2121
A basic test class with various field permutations used to test manifests with custom components
2222
"""
2323

24-
__test__: ClassVar[bool] = (
25-
False # Prevent pytest from thinking that this is a test class, despite the name
26-
)
24+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
2725

2826
subcomponent_field_with_hint: DpathExtractor = field(
2927
default_factory=lambda: DpathExtractor(field_path=[], config={}, parameters={})
@@ -41,9 +39,7 @@ class TestingCustomSubstreamPartitionRouter(SubstreamPartitionRouter):
4139
A test class based on a SubstreamPartitionRouter used for testing manifests that use custom components.
4240
"""
4341

44-
__test__: ClassVar[bool] = (
45-
False # Prevent pytest from thinking that this is a test class, despite the name
46-
)
42+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
4743

4844
custom_field: str
4945
custom_pagination_strategy: PaginationStrategy

unit_tests/sources/declarative/test_yaml_declarative_source.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_source_is_created_if_toplevel_fields_are_known(self):
8787
type: CheckStream
8888
stream_names: ["lists"]
8989
"""
90-
temporary_file = TestFileContent(content=content)
90+
temporary_file = TestFileContent(content)
9191
MockYamlDeclarativeSource(temporary_file.filename)
9292

9393
def test_source_fails_for_invalid_yaml(self):
@@ -105,7 +105,7 @@ def test_source_fails_for_invalid_yaml(self):
105105
type: CheckStream
106106
stream_names: ["lists"]
107107
"""
108-
temporary_file = TestFileContent(content=content)
108+
temporary_file = TestFileContent(content)
109109
with pytest.raises(ParserError):
110110
MockYamlDeclarativeSource(temporary_file.filename)
111111

@@ -128,15 +128,13 @@ def test_source_with_missing_reference_fails(self):
128128
type: CheckStream
129129
stream_names: ["lists"]
130130
"""
131-
temporary_file = TestFileContent(content=content)
131+
temporary_file = TestFileContent(content)
132132
with pytest.raises(UndefinedReferenceException):
133133
MockYamlDeclarativeSource(temporary_file.filename)
134134

135135

136136
class TestFileContent:
137-
__test__: ClassVar[bool] = (
138-
False # Prevent pytest from thinking that this is a test class, despite the name
139-
)
137+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
140138

141139
def __init__(self, content):
142140
self.file = tempfile.NamedTemporaryFile(mode="w", delete=False)

unit_tests/sources/file_based/scenarios/check_scenarios.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@
140140
.set_source_builder(
141141
_base_failure_scenario.source_builder.copy().set_stream_reader(
142142
TestErrorListMatchingFilesInMemoryFilesStreamReader(
143-
files=_base_failure_scenario.source_builder._files,
144-
file_type="csv",
143+
files=_base_failure_scenario.source_builder._files, file_type="csv"
145144
)
146145
)
147146
)
@@ -155,8 +154,7 @@
155154
.set_source_builder(
156155
_base_failure_scenario.source_builder.copy().set_stream_reader(
157156
TestErrorOpenFileInMemoryFilesStreamReader(
158-
files=_base_failure_scenario.source_builder._files,
159-
file_type="csv",
157+
files=_base_failure_scenario.source_builder._files, file_type="csv"
160158
)
161159
)
162160
)

unit_tests/sources/file_based/scenarios/scenario_builder.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ def build(
4242

4343

4444
class TestScenario(Generic[SourceType]):
45-
__test__: ClassVar[bool] = (
46-
False # Prevent pytest from thinking that this is a test class, despite the name
47-
)
45+
__test__: ClassVar[bool] = False # Tell Pytest this is not a Pytest class, despite its name
4846

4947
def __init__(
5048
self,

0 commit comments

Comments
 (0)