summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xOmni/Bild/Example.py16
-rwxr-xr-xOmni/Llamacpp.py15
-rw-r--r--Omni/Test.py2
3 files changed, 22 insertions, 11 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"))
diff --git a/Omni/Llamacpp.py b/Omni/Llamacpp.py
index eac08fd..bf44d5e 100755
--- a/Omni/Llamacpp.py
+++ b/Omni/Llamacpp.py
@@ -10,6 +10,9 @@ sure llama-cpp still works in case I need/want to switch at some point.
# : out llamacpp-test
# : run llama-cpp
+import Omni.App as App
+import Omni.Log as Log
+import Omni.Test as Test
import os
import sys
import unittest
@@ -23,18 +26,10 @@ class TestLlamaCpp(unittest.TestCase):
self.assertIn("llama-cpp", os.environ.get("PATH", ""))
-def test() -> None:
- """Run this module's test suite."""
- suite = unittest.TestSuite()
- suite.addTests(
- unittest.defaultTestLoader.loadTestsFromTestCase(TestLlamaCpp),
- )
- unittest.TextTestRunner().run(suite)
-
-
def main() -> None:
"""Entrypoint."""
if sys.argv[1] == "test":
- test()
+ Log.setup()
+ Test.run(App.Area.Test, [TestLlamaCpp])
else:
sys.exit(0)
diff --git a/Omni/Test.py b/Omni/Test.py
index 495334a..57270f9 100644
--- a/Omni/Test.py
+++ b/Omni/Test.py
@@ -6,6 +6,8 @@ import Omni.Log as Log
import typing
import unittest
+TestCase = unittest.TestCase
+
def run(area: App.Area, tests: list[typing.Any]) -> None:
"""Run the given tests with loglevel determined by area."""