Skip to content

Commit

Permalink
Source Marketo: Increase test coverage, update QL (#33075)
Browse files Browse the repository at this point in the history
Co-authored-by: pnilan <pnilan@users.noreply.github.com>
  • Loading branch information
pnilan and pnilan committed Jan 11, 2024
1 parent 72b87e6 commit 1da4dbc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
data:
ab_internal:
ql: 400
ql: 200
sl: 200
allowedHosts:
hosts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import tracemalloc
from functools import partial
from unittest.mock import ANY, Mock, patch
from unittest.mock import ANY, MagicMock, Mock, patch

import pendulum
import pytest
Expand All @@ -21,6 +21,7 @@
MarketoExportCreate,
MarketoStream,
Programs,
Segmentations,
SourceMarketo,
)

Expand Down Expand Up @@ -317,10 +318,40 @@ def test_check_connection(config, requests_mock, status_code, response, is_conne
("2020-08-01", "%Y-%m-%dT%H:%M:%SZ%z", "2020-08-01"),
),
)
def test_normalize_datetime(config, input, format, expected_result):
def test_programs_normalize_datetime(config, input, format, expected_result):
stream = Programs(config)
assert stream.normalize_datetime(input, format) == expected_result

def test_programs_next_page_token(config):
mock_json = MagicMock()
mock_json.return_value = {"result": [{"test": 'testValue'}]}
mocked_response = MagicMock()
mocked_response.json = mock_json
stream = Programs(config)
result = stream.next_page_token(mocked_response)
assert result == {"offset": 201}

@pytest.mark.parametrize("input, stream_state, expected_result",[(
{"result": [{"id": "1", "createdAt": "2020-07-01T00:00:00Z+0000", "updatedAt": "2020-07-01T00:00:00Z+0000"}]},
{"updatedAt": "2020-06-01T00:00:00Z"},
[{"id": "1", "createdAt": "2020-07-01T00:00:00Z", "updatedAt": "2020-07-01T00:00:00Z"}],
)],
)
def test_programs_parse_response(mocker, config, input, stream_state, expected_result):
response = requests.Response()
mocker.patch.object(response, "json", return_value=input)
stream = Programs(config)
result = stream.parse_response(response, stream_state)
assert list(result) == expected_result

def test_segmentations_next_page_token(config):
mock_json = MagicMock()
mock_json.return_value = {"result": [{"test": 'testValue'}]}
mocked_response = MagicMock()
mocked_response.json = mock_json
stream = Segmentations(config)
result = stream.next_page_token(mocked_response)
assert result == {"offset": 201}

today = pendulum.now()
yesterday = pendulum.now().subtract(days=1).strftime("%Y-%m-%dT%H:%M:%SZ")
Expand Down

0 comments on commit 1da4dbc

Please sign in to comment.