-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Source Marketo: handle null responses (#33623)
Co-authored-by: richa-rochna <[email protected]> Co-authored-by: Richa Rochna <[email protected]>
- Loading branch information
1 parent
52c5f58
commit 2003bc2
Showing
5 changed files
with
89 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
import pendulum | ||
import pytest | ||
from airbyte_cdk.models.airbyte_protocol import SyncMode | ||
from source_marketo.source import Activities, Campaigns, Leads, MarketoStream, Programs, SourceMarketo | ||
from source_marketo.source import Activities, Campaigns, IncrementalMarketoStream, Leads, MarketoStream, Programs, SourceMarketo | ||
|
||
|
||
def test_create_export_job(mocker, send_email_stream, caplog): | ||
|
@@ -314,3 +314,56 @@ def test_get_updated_state(config, latest_record, current_state, expected_state) | |
if expected_state == "start_date": | ||
expected_state = {"updatedAt": config["start_date"]} | ||
assert stream.get_updated_state(latest_record, current_state) == expected_state | ||
|
||
|
||
def test_filter_null_bytes(config): | ||
stream = Leads(config) | ||
|
||
test_lines = [ | ||
"Hello\x00World\n", | ||
"Name,Email\n", | ||
"John\x00Doe,[email protected]\n" | ||
] | ||
expected_lines = [ | ||
"HelloWorld\n", | ||
"Name,Email\n", | ||
"JohnDoe,[email protected]\n" | ||
] | ||
filtered_lines = stream.filter_null_bytes(test_lines) | ||
for expected_line, filtered_line in zip(expected_lines, filtered_lines): | ||
assert expected_line == filtered_line | ||
|
||
|
||
def test_csv_rows(config): | ||
stream = Leads(config) | ||
|
||
test_lines = [ | ||
"Name,Email\n", | ||
"John Doe,[email protected]\n", | ||
"Jane Doe,[email protected]\n" | ||
] | ||
expected_records = [ | ||
{"Name": "John Doe", "Email": "[email protected]"}, | ||
{"Name": "Jane Doe", "Email": "[email protected]"} | ||
] | ||
records = stream.csv_rows(test_lines) | ||
for expected_record, record in zip(expected_records, records): | ||
assert expected_record == record | ||
|
||
def test_availablity_strategy(config): | ||
stream = Leads(config) | ||
assert stream.availability_strategy == None | ||
|
||
def test_path(config): | ||
stream = MarketoStream(config) | ||
assert stream.path() == "rest/v1/marketo_stream.json" | ||
|
||
def test_get_state(config): | ||
stream = IncrementalMarketoStream(config) | ||
assert stream.state == {} | ||
|
||
def test_set_tate(config): | ||
stream = IncrementalMarketoStream(config) | ||
expected_state = {"id": 1} | ||
stream.state = expected_state | ||
assert stream._state == expected_state |
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