diff --git a/airbyte-integrations/connectors/source-dixa/source_dixa/schemas/conversation_export.json b/airbyte-integrations/connectors/source-dixa/source_dixa/schemas/conversation_export.json index 2387365e8cba..ce361f3f7b53 100644 --- a/airbyte-integrations/connectors/source-dixa/source_dixa/schemas/conversation_export.json +++ b/airbyte-integrations/connectors/source-dixa/source_dixa/schemas/conversation_export.json @@ -42,46 +42,49 @@ "type": ["null", "string"] }, "ratings": { - "type": "object", - "properties": { - "rating_score": { - "type": ["null", "integer"] - }, - "rating_message": { - "type": ["null", "string"] - }, - "rating_type": { - "type": ["null", "string"] - }, - "rating_created_timestamp": { - "type": ["null", "integer"] - }, - "rating_offered_timestamp": { - "type": ["null", "integer"] - }, - "rating_status": { - "type": ["null", "string"] - }, - "rating_language": { - "type": ["null", "string"] - }, - "rating_modified_timestamp": { - "type": ["null", "integer"] - }, - "rating_rated_timestamp": { - "type": ["null", "integer"] - }, - "rating_scheduled_timestamp": { - "type": ["null", "integer"] - }, - "rating_scheduled_for_timestamp": { - "type": ["null", "integer"] - }, - "rating_unscheduled_timestamp": { - "type": ["null", "integer"] - }, - "rating_cancelled_timestamp": { - "type": ["null", "integer"] + "type": "array", + "items": { + "type": "object", + "properties": { + "rating_score": { + "type": ["null", "integer"] + }, + "rating_message": { + "type": ["null", "string"] + }, + "rating_type": { + "type": ["null", "string"] + }, + "rating_created_timestamp": { + "type": ["null", "integer"] + }, + "rating_offered_timestamp": { + "type": ["null", "integer"] + }, + "rating_status": { + "type": ["null", "string"] + }, + "rating_language": { + "type": ["null", "string"] + }, + "rating_modified_timestamp": { + "type": ["null", "integer"] + }, + "rating_rated_timestamp": { + "type": ["null", "integer"] + }, + "rating_scheduled_timestamp": { + "type": ["null", "integer"] + }, + "rating_scheduled_for_timestamp": { + "type": ["null", "integer"] + }, + "rating_unscheduled_timestamp": { + "type": ["null", "integer"] + }, + "rating_cancelled_timestamp": { + "type": ["null", "integer"] + } } } }, diff --git a/airbyte-integrations/connectors/source-dixa/unit_tests/unit_test.py b/airbyte-integrations/connectors/source-dixa/unit_tests/unit_test.py index 24c10981e97f..c6806f54c012 100644 --- a/airbyte-integrations/connectors/source-dixa/unit_tests/unit_test.py +++ b/airbyte-integrations/connectors/source-dixa/unit_tests/unit_test.py @@ -20,9 +20,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# - -from datetime import datetime +from datetime import datetime, timezone import pytest from source_dixa.source import ConversationExport @@ -30,7 +28,9 @@ @pytest.fixture def conversation_export(): - return ConversationExport(start_date=datetime(year=2021, month=7, day=1, hour=12), batch_size=1, logger=None) + return ConversationExport( + start_date=datetime(year=2021, month=7, day=1, hour=12, tzinfo=timezone.utc), batch_size=1, logger=None + ) def test_validate_ms_timestamp_with_valid_input(): @@ -65,19 +65,32 @@ def test_add_days_to_ms_timestamp(): def test_stream_slices_without_state(conversation_export): - conversation_export.end_timestamp = 1625263200001 # 2021-07-03 00:00:00 + 1 ms + conversation_export.end_timestamp = 1625270400001 # 2021-07-03 00:00:00 + 1 ms expected_slices = [ - {"updated_after": 1625133600000, "updated_before": 1625220000000}, # 2021-07-01 12:00:00 # 2021-07-02 12:00:00 - {"updated_after": 1625220000000, "updated_before": 1625263200001}, + { + 'updated_after': 1625140800000, # 2021-07-01 12:00:00 + 'updated_before': 1625227200000 # 2021-07-02 12:00:00 + }, + { + 'updated_after': 1625227200000, + 'updated_before': 1625270400001 + } ] actual_slices = conversation_export.stream_slices() assert actual_slices == expected_slices def test_stream_slices_without_state_large_batch(): - conversation_export = ConversationExport(start_date=datetime(year=2021, month=7, day=1, hour=12), batch_size=31, logger=None) - conversation_export.end_timestamp = 1625263200001 # 2021-07-03 00:00:00 + 1 ms - expected_slices = [{"updated_after": 1625133600000, "updated_before": 1625263200001}] # 2021-07-01 12:00:00 + conversation_export = ConversationExport( + start_date=datetime(year=2021, month=7, day=1, hour=12, tzinfo=timezone.utc), batch_size=31, logger=None + ) + conversation_export.end_timestamp = 1625270400001 # 2021-07-03 00:00:00 + 1 ms + expected_slices = [ + { + 'updated_after': 1625140800000, # 2021-07-01 12:00:00 + 'updated_before': 1625270400001 + } + ] actual_slices = conversation_export.stream_slices() assert actual_slices == expected_slices @@ -93,17 +106,27 @@ def test_stream_slices_with_start_timestamp_larger_than_state(): """ Test that if start_timestamp is larger than state, then start at start_timestamp. """ - conversation_export = ConversationExport(start_date=datetime(year=2021, month=12, day=1), batch_size=31, logger=None) + conversation_export = ConversationExport( + start_date=datetime(year=2021, month=12, day=1, tzinfo=timezone.utc), batch_size=31, + logger=None + ) conversation_export.end_timestamp = 1638360000001 # 2021-12-01 12:00:00 + 1 ms - expected_slices = [{"updated_after": 1638313200000, "updated_before": 1638360000001}] # 2021-07-01 12:00:00 - actual_slices = conversation_export.stream_slices(stream_state={"updated_at": 1625220000000}) # # 2021-07-02 12:00:00 + expected_slices = [ + { + 'updated_after': 1638316800000, # 2021-07-01 12:00:00 + 'updated_before': 1638360000001 + } + ] + actual_slices = conversation_export.stream_slices( + stream_state={'updated_at': 1625220000000} # # 2021-07-02 12:00:00 + ) assert actual_slices == expected_slices def test_get_updated_state_without_state(conversation_export): - assert conversation_export.get_updated_state(current_stream_state=None, latest_record={"updated_at": 1625263200000}) == { - "updated_at": 1625133600000 - } + assert conversation_export.get_updated_state( + current_stream_state=None, latest_record={'updated_at': 1625263200000} + ) == {'updated_at': 1625140800000} def test_get_updated_state_with_bigger_state(conversation_export):