예제 #1
0
def test_extract(df, df2, mocker):
    mock_extract_zip = mocker.patch('toucan_data_sdk.sdk.extract_zip')
    mock_extract_zip.return_value = 1

    # 1. Is a (valid) zip file
    zip_content = default_zip_file(df, df2)
    res = extract(zip_content)

    assert mock_extract_zip.call_count == 1
    assert res == 1

    # 2. Is not a zip file
    mock_is_zip_file = mocker.patch('zipfile.is_zipfile')
    mock_is_zip_file.return_value = False

    with pytest.raises(DataSdkError):
        extract(zip_content)

    # 3. Unknown input data
    with pytest.raises(DataSdkError):
        extract(b'string is not a valid input')
예제 #2
0
def gen_zipfile():
    return copy.deepcopy(default_zip_file(DF, DF2))