From 2da422abc5243f3dad6ccc22fa6aca34f406d156 Mon Sep 17 00:00:00 2001 From: DasMoorhuhn Date: Thu, 7 Dec 2023 19:59:51 +0100 Subject: [PATCH] make pytests --- .coveragerc | 2 ++ .gitignore | 4 +++- README.md | 6 ++++++ pytest.ini | 3 +++ tests/test_exif_data.py | 24 ++++++++++-------------- 5 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 .coveragerc create mode 100644 pytest.ini diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..fe8645c --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +omit = tests/*, __init__.py \ No newline at end of file diff --git a/.gitignore b/.gitignore index af0af93..b3b495e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ __pycache__/ .idea/ app/ -*.log \ No newline at end of file +*/coverage/ +*.log +.coverage diff --git a/README.md b/README.md index 6d51a82..97dbde6 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,9 @@ Dies ist die dritte Version von AutoPicture. # Erste Schritte +# Tests + +```bash +python3.10 -m pytest --no-header -rfp --cov --cov-report html:tests/coverage --cov-report xml:tests/coverage/coverage.xml tests/ +``` + diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..11422c9 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +pythonpath = . +addopts = --ignore-glob=**/tests/** \ No newline at end of file diff --git a/tests/test_exif_data.py b/tests/test_exif_data.py index c1fb0c9..51a6666 100644 --- a/tests/test_exif_data.py +++ b/tests/test_exif_data.py @@ -1,19 +1,15 @@ -import unittest -import sys -sys.path.append("../") - from src.exif_data import ExifData +import unittest class TestExifData(unittest.TestCase): - exif_data = ExifData(image_path="/my/path/lol", - image_name="Secret.png", - make="SALAMI", - day=10, - month=10, - year=1010, - time=1237127392 - ) + def test_exif_data(self): + exif_data = ExifData(image_path="/path/to/image", + image_name="Image.jpeg", + make="CAMERA", + month=12, + day=12, + year=2023, + time=1278897213) - assert exif_data.name == "Secret.png" - assert exif_data.make == "SALAMI" + assert exif_data.make == "CAMERA"