From c055907c74ad9f05b0386d0091e1a87d15af519e Mon Sep 17 00:00:00 2001 From: Tiffany Timbers Date: Thu, 23 Nov 2023 16:38:47 -0800 Subject: [PATCH 1/3] laying out plans for test and creating test objects --- Dockerfile | 6 ++- src/breast_cancer_predictor_report.ipynb | 2 - src/read_zip.py | 15 ++++++++ tests/README.md | 9 +++++ tests/empty.zip | Bin 0 -> 22 bytes tests/files_txt_subdir.zip | Bin 0 -> 246 bytes tests/files_txt_xlsx.zip | Bin 0 -> 4470 bytes tests/generate_test_zip_files.py | 46 +++++++++++++++++++++++ tests/test_read_zip.py | 42 +++++++++++++++++++++ 9 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 src/read_zip.py create mode 100644 tests/README.md create mode 100644 tests/empty.zip create mode 100644 tests/files_txt_subdir.zip create mode 100644 tests/files_txt_xlsx.zip create mode 100644 tests/generate_test_zip_files.py create mode 100644 tests/test_read_zip.py diff --git a/Dockerfile b/Dockerfile index bfca05f..f8693f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,11 @@ FROM quay.io/jupyter/minimal-notebook:notebook-7.0.6 # install necessary packages for analysis RUN conda install -y \ python=3.11.6 \ - altair=5.1.2 \ + altair=altair \ pandas=2.1.2 \ ipykernel=6.26.0 \ scikit-learn=1.3.2 \ requests=2.31.0 \ - notebook=6.5.4 + notebook=7.0.6 \ + pytest=7.4.3 \ + openpyxl=3.1.2 diff --git a/src/breast_cancer_predictor_report.ipynb b/src/breast_cancer_predictor_report.ipynb index 0060371..dbfaf57 100644 --- a/src/breast_cancer_predictor_report.ipynb +++ b/src/breast_cancer_predictor_report.ipynb @@ -87,8 +87,6 @@ "with open(\"../data/raw/breast+cancer+wisconsin+original.zip\", 'wb') as f:\n", " f.write(request.content)\n", "\n", - "pd.arrays\n", - "\n", "with zipfile.ZipFile(\"../data/raw/breast+cancer+wisconsin+original.zip\", 'r') as zip_ref:\n", " zip_ref.extractall(\"../data/raw\")" ] diff --git a/src/read_zip.py b/src/read_zip.py new file mode 100644 index 0000000..b4a6520 --- /dev/null +++ b/src/read_zip.py @@ -0,0 +1,15 @@ +def read_zip(url, directory): + """ + Read a zip file from the given URL and extract its contents to the specified directory. + + Parameters: + ---------- + url : str + The URL of the zip file to be read. + directory : str + The directory where the contents of the zip file will be extracted. + + Returns: + ------- + None + """ diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..6087516 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,9 @@ +## How to run the test suite + +### Preparation of test zip files +The test zip files used in `test_read_zip.py` were genereated +by running the `generate_test_zip_files.py` script in the `tests` directory. +These files need to exist in the remote GitHub repository for the tests to pass. +If for some reason they go missing from the remote repository, +we can re-run the `generate_test_zip_files.py` script to re-generate them +and then push them to the remote repository. \ No newline at end of file diff --git a/tests/empty.zip b/tests/empty.zip new file mode 100644 index 0000000000000000000000000000000000000000..15cb0ecb3e219d1701294bfdf0fe3f5cb5d208e7 GIT binary patch literal 22 NcmWIWW@Tf*000g10H*)| literal 0 HcmV?d00001 diff --git a/tests/files_txt_subdir.zip b/tests/files_txt_subdir.zip new file mode 100644 index 0000000000000000000000000000000000000000..b6d203801a529e1d02bb2d27fbc8ddeef2fecd6c GIT binary patch literal 246 zcmWIWW@Zs#U|`^2c*Ix{zG)rDWo{sk6N*bxi%SgkN-9dUJ$3a0Jv?JR|x zDlSb*$t=l$qy)*AQbLKZ^&OBev$46To51$qQ0Newt;P}6;K-?QA{kswW@A%kx`-lqr z`1=T`3JL3|s0ym$1GN7S0Y}}Lrcwd`9n=5-$zSTg$NQ?rQXj12eg zd2Sbm{1)GWX3=fys(!w%r*FzeR)6pXi7ybMnQq$`0VjbktX@eJMCUNT*N;BJ3#%YL_v_ ztWFfx*Dsyor|S-)>Eqv>AL8ZKlo~s;50`+%kKneS; z%;vAb9oXLBYezZ~Hli6y1$Qj8bDOiCHVSn35K>X@fuqDtJtmBbiG;?;(yN&d0be5i zq;IJ!(=bH*c11VhiiebteVrD1bc;-j-O6lz=pkO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F*crx5q0&oj_^VqQWA?oNm0e*9Qi({;urCs0M@U}=_{ifP`^jp1~Up5#F zrP*aQ41H}NJ%u`9OTG}%R>#4m#ryx2$6tr>Ka~gjC;lTq{u}#m@9}R40LX)h{RjKU Xf@rG~5dL$+{o5XY^YE`L0Ra95D%+!r literal 0 HcmV?d00001 diff --git a/tests/generate_test_zip_files.py b/tests/generate_test_zip_files.py new file mode 100644 index 0000000..2d0e6c5 --- /dev/null +++ b/tests/generate_test_zip_files.py @@ -0,0 +1,46 @@ +import pytest +import os +import openpyxl +import zipfile +import shutil + +# Create a directory named 'subdir' +os.makedirs('subdir', exist_ok=True) + +# Create 'test1.txt' and write "test data" to it +with open('test1.txt', 'w') as file: + file.write('test data') + +# Create 'test2.txt' inside 'subdir' and write "test data" to it +with open('subdir/test2.txt', 'w') as file: + file.write('test data') + +# Create 'test1.xlsx' and write "test data" to it +workbook = openpyxl.Workbook() +worksheet = workbook.active +worksheet.cell(row=1, column=1, value='test data') +workbook.save('test1.xlsx') + +# Case 1 - Create a zip file containing 'test1.txt' and 'test1.xlsx' +with zipfile.ZipFile('files_txt_xlsx.zip', 'w', zipfile.ZIP_DEFLATED) as zipf: + zipf.write('test1.txt') + zipf.write('test1.xlsx') + +# Case 2 - Create a zip file containing 'test1.txt' and 'subdir/test2.txt' +with zipfile.ZipFile('files_txt_subdir.zip', 'w', zipfile.ZIP_DEFLATED) as zipf: + zipf.write('test1.txt') + zipf.write('subdir/test2.txt') + +# Case 3 - Create an empty zip file +with zipfile.ZipFile('empty.zip', 'w', zipfile.ZIP_DEFLATED) as zipf: + pass + +# Clean up the files and directories created +test_files = ['test1.txt', 'test1.xlsx'] + +for file in test_files: + if os.path.exists(file): + os.remove(file) + +if os.path.exists("subdir"): + shutil.rmtree("subdir") diff --git a/tests/test_read_zip.py b/tests/test_read_zip.py new file mode 100644 index 0000000..566efc8 --- /dev/null +++ b/tests/test_read_zip.py @@ -0,0 +1,42 @@ +import pytest +import os +import shutil + +# Test files setup +# setup empty directory for data files to be downloaded to +if not os.path.exists('test_zip_data1'): + os.makedirs('test_zip_data1') + +# setup directory that contains a file for data files to be downloaded to +if not os.path.exists('test_zip_data2'): + os.makedirs('test_zip_data2') +with open('test_zip_data2/test3.txt', 'w') as file: + pass # The 'pass' statement does nothing, creating an empty file + +# test read_zip function can download and extract a zip file containing files +# and subdirectories containing files +def test_read_zip_function(): + # add tests here + + +# test read_zip function throws an error if the zip file is empty +def test_read_zip_error_on_empty(): + # add tests here + + +# test read_zip function throws an error if the input URL is invalid +# (e.g., points to a non-existent file or a non-zip file) +def test_read_zip_error_on_invalid_url(): + # add tests here + + +# test read_zip function throws an error +# if the directory path provided does not exist +def test_read_zip_error_on_missing_dir(): + # add tests here + + +# clean up data directory +if os.path.exists("subdir"): + shutil.rmtree("subdir") + From 2e688747e0da6fc97735cf7ffce7a6ca98626fea Mon Sep 17 00:00:00 2001 From: Tiffany Timbers Date: Thu, 23 Nov 2023 20:35:57 -0800 Subject: [PATCH 2/3] fixing Dockerfile and removing excel file type dependency as it wasn't really needed --- tests/files_txt_csv.zip | Bin 0 -> 232 bytes tests/files_txt_subdir.zip | Bin 246 -> 351 bytes tests/files_txt_xlsx.zip | Bin 4470 -> 0 bytes tests/generate_test_zip_files.py | 29 +++++++++++++---------------- 4 files changed, 13 insertions(+), 16 deletions(-) create mode 100644 tests/files_txt_csv.zip delete mode 100644 tests/files_txt_xlsx.zip diff --git a/tests/files_txt_csv.zip b/tests/files_txt_csv.zip new file mode 100644 index 0000000000000000000000000000000000000000..f41e24aaae6acf3f8acfe082b67200755df24083 GIT binary patch literal 232 zcmWIWW@Zs#U|`^2$Xrq$zG)rDWo{sk6N*bxi%SgkN-9dUJ$3a0Jv?aG%+wNX*7ar1G^Yq8@fXg+ERc_bY};6v$BCyFazNlAUzkvVE_PIFhs!s delta 91 zcmcc5^o@}>z?+#xgn@y9gW(Zl#YA3xW)M{l$qy)*AQbLKZ^&OBev$46To51$qQ0Newt;P}6;K-?QA{kswW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r983F2rp$ z*zFa4rZJ!iI9ck-T~6|N>!lGsPTl}XXWPNL9DsHXE-yoBG|>qem??{u6`v{_6_Q3_ z0taFzGG8&3y-vAv(X-J`{uUi?JLH!X`=a>AjzV)z-vt{?gj(iI{kR6~p>Pq`p}3U} zqxB)G*Et))Rt^SoM3Vxk`$)1)rB9H{36BTHDM;T)4lf<5!a#GorR8y&>qQX7-3|UK z&h6UmGRLL$-5rtHiAOCC!!ko7TJC_g>HY2(5t2G1uA77qO5K&aM*9ZdHS6`e?;qrP zBczu&j;&F*crx5q0&oj_^VqQWA?oNm0e*9Qi({;urCs0M@U}=_{ifP`^jp1~Up5#F zrP*aQ41H}NJ%u`9OTG}%R>#4m#ryx2$6tr>Ka~gjC;lTq{u}#m@9}R40LX)h{RjKU Xf@rG~5dL$+{o5XY^YE`L0Ra95D%+!r diff --git a/tests/generate_test_zip_files.py b/tests/generate_test_zip_files.py index 2d0e6c5..c227144 100644 --- a/tests/generate_test_zip_files.py +++ b/tests/generate_test_zip_files.py @@ -1,6 +1,4 @@ -import pytest import os -import openpyxl import zipfile import shutil @@ -11,32 +9,31 @@ with open('test1.txt', 'w') as file: file.write('test data') -# Create 'test2.txt' inside 'subdir' and write "test data" to it -with open('subdir/test2.txt', 'w') as file: - file.write('test data') +# Create 'test2.csv' and write "test data" to it +with open('test2.csv', 'w') as file: + file.write('test,data') -# Create 'test1.xlsx' and write "test data" to it -workbook = openpyxl.Workbook() -worksheet = workbook.active -worksheet.cell(row=1, column=1, value='test data') -workbook.save('test1.xlsx') +# Create 'test3.txt' inside 'subdir' and write "test data" to it +with open('subdir/test3.txt', 'w') as file: + file.write('test data') -# Case 1 - Create a zip file containing 'test1.txt' and 'test1.xlsx' -with zipfile.ZipFile('files_txt_xlsx.zip', 'w', zipfile.ZIP_DEFLATED) as zipf: +# Case 1 - Create a zip file containing 'test1.txt' and 'test2.csv' +with zipfile.ZipFile('files_txt_csv.zip', 'w', zipfile.ZIP_DEFLATED) as zipf: zipf.write('test1.txt') - zipf.write('test1.xlsx') + zipf.write('test2.csv') -# Case 2 - Create a zip file containing 'test1.txt' and 'subdir/test2.txt' +# Case 2 - Create a zip file containing 'test1.txt', test2.csv and 'subdir/test2.txt' with zipfile.ZipFile('files_txt_subdir.zip', 'w', zipfile.ZIP_DEFLATED) as zipf: zipf.write('test1.txt') - zipf.write('subdir/test2.txt') + zipf.write('test2.csv') + zipf.write('subdir/test3.txt') # Case 3 - Create an empty zip file with zipfile.ZipFile('empty.zip', 'w', zipfile.ZIP_DEFLATED) as zipf: pass # Clean up the files and directories created -test_files = ['test1.txt', 'test1.xlsx'] +test_files = ['test1.txt', 'test2.csv'] for file in test_files: if os.path.exists(file): From 14112300d18f078e6ac5ab283504c8ce2b21a92b Mon Sep 17 00:00:00 2001 From: Tiffany Timbers Date: Thu, 23 Nov 2023 20:37:36 -0800 Subject: [PATCH 3/3] Dockerfile fix --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f8693f1..c6ebd0d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,11 +4,10 @@ FROM quay.io/jupyter/minimal-notebook:notebook-7.0.6 # install necessary packages for analysis RUN conda install -y \ python=3.11.6 \ - altair=altair \ + altair=5.1.2 \ pandas=2.1.2 \ ipykernel=6.26.0 \ scikit-learn=1.3.2 \ requests=2.31.0 \ notebook=7.0.6 \ - pytest=7.4.3 \ - openpyxl=3.1.2 + pytest=7.4.3