From 01d25822be3378511cb478ae0f91439cc705c899 Mon Sep 17 00:00:00 2001 From: gsganden Date: Sat, 3 Aug 2019 11:54:50 -0500 Subject: [PATCH] Allow capitalized extensions, add basic tests --- README.md | 4 ++++ autofocus/predict/app/utils.py | 3 ++- requirements-dev.txt | 6 ++++++ tests/test_dummy.py | 3 --- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 requirements-dev.txt delete mode 100644 tests/test_dummy.py diff --git a/README.md b/README.md index d9d626b..42dbf34 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,10 @@ tar -xvf $(pwd)/data/${FILENAME} -C $(pwd)/data/ A third dataset from the Lincoln Park Zoo's Urban Wildlife Institute contains unlabeled three-image bursts from 2018. It takes up 5.7GB uncompressed. To get this data, follow the same steps as for the 2012-2014 dataset, but replace `FILENAME=lpz_2016_2017_processed.tar.gz` with `FILENAME=lpz_2018.tar.gz`. +## Running Tests + +To test the app, run `pip install -r requirements-dev.txt` and then `pytest`. The tests assume that the app is running locally on port `8000` according to the instructions above.`` + ## Example Images ![buck](./gallery/buck.jpeg) diff --git a/autofocus/predict/app/utils.py b/autofocus/predict/app/utils.py index a6fca64..ce201cc 100644 --- a/autofocus/predict/app/utils.py +++ b/autofocus/predict/app/utils.py @@ -1,3 +1,4 @@ +from pathlib import Path from zipfile import ZipFile @@ -11,7 +12,7 @@ def allowed_file(filename, allowed_extensions): bool: whether the filename is in allowed extensions """ - return "." in filename and filename.rsplit(".", 1)[1] in allowed_extensions + return Path(filename).suffix.lower().replace(".", "") in allowed_extensions def list_zip_files(path): diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..637bcfd --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,6 @@ +black +flake8 +flake8-docstrings +flake8-import-order +pydocstyle<4.0.0 +pytest diff --git a/tests/test_dummy.py b/tests/test_dummy.py deleted file mode 100644 index 0845842..0000000 --- a/tests/test_dummy.py +++ /dev/null @@ -1,3 +0,0 @@ -# Dummy test for getting CI set up. -def test_dummy(): - assert True