-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Source Smartsheets: fix scrambled columns bug (#11911)
* #5520 fix scrambled columns bug * #5520 source smartsheets: add changelog item * #5520 move pytest to optional setup requirements * #5520 source smartsheets: add two unit tests * auto-bump connector version Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
- Loading branch information
Showing
9 changed files
with
95 additions
and
70 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
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
Empty file.
46 changes: 46 additions & 0 deletions
46
airbyte-integrations/connectors/source-smartsheets/unit_tests/test_source.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,46 @@ | ||
# | ||
# Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import json | ||
from itertools import permutations | ||
from unittest.mock import Mock | ||
|
||
import pytest | ||
from source_smartsheets.source import SourceSmartsheets | ||
|
||
|
||
@pytest.fixture | ||
def config(): | ||
return {"access_token": "token", "spreadsheet_id": "id"} | ||
|
||
|
||
@pytest.fixture(name="catalog") | ||
def configured_catalog(): | ||
stream_mock = Mock() | ||
stream_mock.name = "test" # cannot be used in __init__ | ||
return Mock(streams=[Mock(stream=stream_mock)]) | ||
|
||
|
||
_columns = [ | ||
{"id": "1101932201830276", "title": "id", "type": "TEXT_NUMBER"}, | ||
{"id": "5605531829200772", "title": "first_name", "type": "TEXT_NUMBER"}, | ||
{"id": "3353732015515524", "title": "last_name", "type": "TEXT_NUMBER"}, | ||
] | ||
|
||
|
||
_cells = [ | ||
{"columnId": "1101932201830276", "value": "11"}, | ||
{"columnId": "5605531829200772", "value": "Leonardo"}, | ||
{"columnId": "3353732015515524", "value": "Dicaprio"}, | ||
] | ||
|
||
|
||
@pytest.mark.parametrize(("row", "columns"), (*((perm, _columns) for perm in permutations(_cells)), ([], _columns), ([], []))) | ||
def test_different_cell_order_produces_one_result(mocker, config, catalog, row, columns): | ||
sheet = json.dumps({"name": "test", "totalRowCount": 3, "columns": columns, "rows": [{"cells": row}] if row else []}) | ||
mocker.patch("smartsheet.Smartsheet", Mock(return_value=Mock(Sheets=Mock(get_sheet=Mock(return_value=sheet))))) | ||
source = SourceSmartsheets() | ||
records = [message.record.data for message in source.read(logger=Mock(), config=config, catalog=catalog, state={})] | ||
expected_records = [] if not row else [{"id": "11", "first_name": "Leonardo", "last_name": "Dicaprio"}] | ||
assert list(records) == expected_records |
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