コード例 #1
0
def test_stream_slices_without_state_large_batch():
    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, "updated_before": 1625270400001}]  # 2021-07-01 12:00:00
    actual_slices = conversation_export.stream_slices()
    assert actual_slices == expected_slices
コード例 #2
0
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, 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": 1638316800000, "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
    assert actual_slices == expected_slices
コード例 #3
0
ファイル: unit_test.py プロジェクト: yevhenii-ldv/airbyte
def test_stream_slices_without_state_large_batch():

    updated_config = config
    updated_config["batch_size"] = 31

    conversation_export = ConversationExport(updated_config)
    conversation_export.end_timestamp = 1625259600000  # 2021-07-03 00:00:00 + 1 ms
    expected_slices = [{
        "updated_after": 1625097600000,
        "updated_before": 1625259600000
    }]  # 2021-07-01 12:00:00 """
    actual_slices = conversation_export.stream_slices()
    assert actual_slices == expected_slices
コード例 #4
0
def test_datetime_to_ms_timestamp():
    assert (
        ConversationExport.datetime_to_ms_timestamp(
            datetime(year=2021, month=7, day=3, hour=11, minute=49, second=40, microsecond=123000, tzinfo=timezone.utc)
        )
        == 1625312980123
    )
コード例 #5
0
ファイル: unit_test.py プロジェクト: yevhenii-ldv/airbyte
def test_stream_slices_with_start_timestamp_larger_than_state():
    #
    # Test that if start_timestamp is larger than state, then start at start_timestamp.
    #
    updated_config = config
    updated_config["start_date"] = "2021-12-01"
    updated_config["batch_size"] = 31

    conversation_export = ConversationExport(updated_config)
    conversation_export.end_timestamp = 1638352800001  # 2021-12-01 12:00:00 + 1 ms
    expected_slices = [{
        "updated_after": 1638316800000,
        "updated_before": 1638352800001
    }]  # 2021-07-01 12:00:00 """
    actual_slices = conversation_export.stream_slices(
        stream_state={"updated_at": 1625216400000})  # # 2021-07-02 12:00:00
    assert actual_slices == expected_slices
コード例 #6
0
ファイル: unit_test.py プロジェクト: yevhenii-ldv/airbyte
def conversation_export():
    return ConversationExport(config)
コード例 #7
0
def test_add_days_to_ms_timestamp():
    assert ConversationExport.add_days_to_ms_timestamp(days=1, milliseconds=1625312980123) == 1625399380123
コード例 #8
0
def test_validate_ms_timestamp_with_invalid_input_length():
    with pytest.raises(ValueError):
        assert ConversationExport._validate_ms_timestamp(1)
コード例 #9
0
def test_validate_ms_timestamp_with_valid_input():
    assert ConversationExport._validate_ms_timestamp(1234567890123) == 1234567890123
コード例 #10
0
def conversation_export():
    return ConversationExport(start_date=datetime(year=2021, month=7, day=1, hour=12, tzinfo=timezone.utc), batch_size=1, logger=None)