From 029d0b7f2540c5b0ba24146d76fee3bfd0a71230 Mon Sep 17 00:00:00 2001 From: Lorena Mesa Date: Wed, 17 Jul 2024 03:22:39 +0000 Subject: [PATCH] Add empty init files for Python modules --- README.md | 4 ++-- __init__.py | 0 main.py | 5 ----- requirements.txt | 2 +- test/__init__.py | 0 test/sample_cases_test.py | 19 +++++++++++++------ 6 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 __init__.py create mode 100644 test/__init__.py diff --git a/README.md b/README.md index 0768b26..def31d1 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Users often work collaboratively in digital environments where a profile picture 3. Identicon's should use accessible colors as specified by [W3](https://www.w3.org/WAI/WCAG21/Techniques/general/G207) ## TODO: -- [ ] Finish script to implement identicon -- [ ] Implement core logic to generate a Python PIL or Tinkr image +- [ ] Finish script to implement identicon with multiple colors +- [X] Implement core logic to generate a Python PIL or Tinkr image - [ ] Write baseline tests - [ ] Add CI/CD with GitHub actions to run tests diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/main.py index 16ad7b0..fdd1a74 100644 --- a/main.py +++ b/main.py @@ -124,8 +124,3 @@ def len_gt_zero(input_str: str): identicon = Identicon(input_str=args.string) identicon.draw_image(filename=args.output) - - # hash_str =convert_string_to_sha_hash("931D387731bBbC988B31220") - # hash_str = convert_string_to_sha_hash("me@lorenamesa.com") - # grid = build_grid(hash_str) - # draw_image(grid, hash_str) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 189c45c..21a06ca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -ruffruff check --fix \ No newline at end of file +ruff \ No newline at end of file diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/sample_cases_test.py b/test/sample_cases_test.py index 9e786db..a31381b 100644 --- a/test/sample_cases_test.py +++ b/test/sample_cases_test.py @@ -1,25 +1,32 @@ #!/usr/bin/env python3 from pathlib import Path +from PIL import Image import subprocess import unittest +from main import Identicon + __author__ = "Lorena Mesa" __email__ = "me@lorenamesa.com" PROJECT_ROOT = Path(__file__).parent.parent.absolute() -class TestHappyPath(unittest.TestCase): - def test_fails_to_create_identicon_with_input_text_missing(self): +class TestUI(unittest.TestCase): + def test_ui_fails_to_create_identicon_with_input_text_missing(self): with self.assertRaises(subprocess.CalledProcessError) as context: - subprocess.check_output(f'python3 {PROJECT_ROOT}/main.py', shell=True, stderr=subprocess.STDOUT).strip() + subprocess.check_output(f"python3 {PROJECT_ROOT}/main.py", shell=True, stderr=subprocess.STDOUT).strip() self.assertIn(context.exception.message, "main.py: error: the following arguments are required: -s/--string") - - def test_creates_identicon_when_input_text_provided(self): - pass +class TestHappyPath(unittest.TestCase): + def test_successfully_creates_identicon(self): + identicon = Identicon("931D387731bBbC988B31220") + identicon.draw_image(filename="output") + image = Image.open(f"{PROJECT_ROOT}/output.png", mode="r") + self.assertIsInstance(image, Image, "Image created is not of type PIL.Image") + # hash_str =convert_string_to_sha_hash("931D387731bBbC988B31220") # hash_str = convert_string_to_sha_hash("me@lorenamesa.com") # grid = build_grid(hash_str)