From f35bd807671cec6f7d7307a55a076582c1177c4c Mon Sep 17 00:00:00 2001 From: Oscar Pocock Date: Thu, 28 Apr 2022 22:17:20 +0100 Subject: [PATCH] Packaged autophotographer and added tests and test pipelines --- .woodpecker.yml => .woodpecker/.lint.yml | 7 ++++++- .woodpecker/.test.yml | 8 ++++++++ pyproject.toml | 3 +++ requirements_dev.txt | 4 ++++ setup.cfg | 26 ++++++++++++++++++++++++ setup.py | 3 +++ test/pytest.ini | 2 ++ test/unit/test_autophotographer.py | 6 ++++++ test/unit/test_dataset.py | 0 9 files changed, 58 insertions(+), 1 deletion(-) rename .woodpecker.yml => .woodpecker/.lint.yml (63%) create mode 100644 .woodpecker/.test.yml create mode 100644 pyproject.toml create mode 100644 requirements_dev.txt create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 test/pytest.ini create mode 100644 test/unit/test_autophotographer.py create mode 100644 test/unit/test_dataset.py diff --git a/.woodpecker.yml b/.woodpecker/.lint.yml similarity index 63% rename from .woodpecker.yml rename to .woodpecker/.lint.yml index f1cd3ef..b6b057b 100644 --- a/.woodpecker.yml +++ b/.woodpecker/.lint.yml @@ -9,4 +9,9 @@ pipeline: commands: - python3.8 -m pip install mypy - mypy src/ -+branches: dev \ No newline at end of file + isort: + image: python:3.8 + commands: + - python3.8 -m pip install isort + - isort --diff src/ +branches: dev \ No newline at end of file diff --git a/.woodpecker/.test.yml b/.woodpecker/.test.yml new file mode 100644 index 0000000..c39f634 --- /dev/null +++ b/.woodpecker/.test.yml @@ -0,0 +1,8 @@ +pipeline: + unit-tests: + image: python:3.8 + commands: + - python3.8 -m pip install -r ./requirements_dev.txt -r ./requirements.txt + - python3.8 -m pip install -e . + - pytest test/ -v +branches: dev \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b28f77b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools >= 43.0.0", "wheel"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..3f4cde1 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,4 @@ +flake8==4.0.1 +pytest==7.1.2 +pytest-cov==3.0.0 +mypy==0.950 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..85d2e19 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,26 @@ +[metadata] +name = autophotographer +description = Select aesthetic frames from a video file +long_description = README.md +author = Oscar Pocock +author_email = osp1@aber.ac.uk +license = GPLv3+ +license_files = LICENSE.txt + +[options] +packages = + autophotographer +python_requires = >=3.8 +package_dir = + =src +zip_safe = no + +[options.extras_require] +testing = + flake8>=4.0 + pytest>=7.1 + pytest-cov>=3.0 + mypy>=0.950 + +[flake8] +max-line-length = 160 \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..483e332 --- /dev/null +++ b/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup +if __name__ == "__main__": + setup() \ No newline at end of file diff --git a/test/pytest.ini b/test/pytest.ini new file mode 100644 index 0000000..90815a2 --- /dev/null +++ b/test/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = "--cov=autophotographer" \ No newline at end of file diff --git a/test/unit/test_autophotographer.py b/test/unit/test_autophotographer.py new file mode 100644 index 0000000..82a7ead --- /dev/null +++ b/test/unit/test_autophotographer.py @@ -0,0 +1,6 @@ +from autophotographer import autophotographer_main +import pytest + +def test_load_config_nonexistent_file(): + with pytest.raises(FileNotFoundError): + autophotographer_main.load_config("blahblahblah") diff --git a/test/unit/test_dataset.py b/test/unit/test_dataset.py new file mode 100644 index 0000000..e69de29