diff options
Diffstat (limited to 'Omni/Bild')
-rwxr-xr-x | Omni/Bild/Example.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Omni/Bild/Example.py b/Omni/Bild/Example.py index 58e941a..7d57890 100755 --- a/Omni/Bild/Example.py +++ b/Omni/Bild/Example.py @@ -8,8 +8,13 @@ Example Python file that also serves as a test case for bild. # : out example # : dep cryptography import cryptography.fernet +import Omni.App as App +import Omni.Log as Log +import Omni.Test as Test import sys +log = Log.setup() + def cryptic_hello(name: str) -> str: """ @@ -23,6 +28,7 @@ def cryptic_hello(name: str) -> str: key = cryptography.fernet.Fernet.generate_key() f = cryptography.fernet.Fernet(key) token = f.encrypt(hello(name).encode("utf-8")) + log.info("attempting decryption") ret = f.decrypt(token).decode("utf-8") if ret != hello(name): msg = "en/decryption failed!" @@ -35,8 +41,16 @@ def hello(name: str) -> str: return f"Hello {name}" +class TestExample(Test.TestCase): + """Test the Example module.""" + + def test_hello(self) -> None: + """Test `hello` function.""" + self.assertEqual("Hello Ben", hello("Ben")) + + def main() -> None: """Entrypoint.""" if "test" in sys.argv: - sys.stdout.write("testing success") + Test.run(App.Area.Test, [TestExample]) sys.stdout.write(cryptic_hello("world")) |