|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 |
|
3 | 3 | from pathlib import Path |
| 4 | +from PIL import Image |
4 | 5 | import subprocess |
5 | 6 | import unittest |
6 | 7 |
|
| 8 | +from main import Identicon |
| 9 | + |
7 | 10 | __author__ = "Lorena Mesa" |
8 | 11 | __email__ = "me@lorenamesa.com" |
9 | 12 |
|
10 | 13 | PROJECT_ROOT = Path(__file__).parent.parent.absolute() |
11 | 14 |
|
12 | 15 |
|
13 | | -class TestHappyPath(unittest.TestCase): |
14 | | - def test_fails_to_create_identicon_with_input_text_missing(self): |
| 16 | +class TestUI(unittest.TestCase): |
| 17 | + def test_ui_fails_to_create_identicon_with_input_text_missing(self): |
15 | 18 | with self.assertRaises(subprocess.CalledProcessError) as context: |
16 | | - subprocess.check_output(f'python3 {PROJECT_ROOT}/main.py', shell=True, stderr=subprocess.STDOUT).strip() |
| 19 | + subprocess.check_output(f"python3 {PROJECT_ROOT}/main.py", shell=True, stderr=subprocess.STDOUT).strip() |
17 | 20 | self.assertIn(context.exception.message, "main.py: error: the following arguments are required: -s/--string") |
18 | | - |
19 | | - def test_creates_identicon_when_input_text_provided(self): |
20 | | - pass |
21 | 21 |
|
22 | 22 |
|
| 23 | +class TestHappyPath(unittest.TestCase): |
| 24 | + def test_successfully_creates_identicon(self): |
| 25 | + identicon = Identicon("931D387731bBbC988B31220") |
| 26 | + identicon.draw_image(filename="output") |
| 27 | + image = Image.open(f"{PROJECT_ROOT}/output.png", mode="r") |
| 28 | + self.assertIsInstance(image, Image, "Image created is not of type PIL.Image") |
| 29 | + |
23 | 30 | # hash_str =convert_string_to_sha_hash("931D387731bBbC988B31220") |
24 | 31 | # hash_str = convert_string_to_sha_hash("me@lorenamesa.com") |
25 | 32 | # grid = build_grid(hash_str) |
|
0 commit comments