3
0
Fork 0

feat: add basic support for progress indicators

This commit is contained in:
Lance Edgar 2024-08-24 17:19:50 -05:00
parent 110ff69d6d
commit 4b9db13b8f
9 changed files with 248 additions and 1 deletions

View file

@ -12,6 +12,7 @@ import pytest
import wuttjamaican.enum
from wuttjamaican import app
from wuttjamaican.progress import ProgressBase
from wuttjamaican.conf import WuttaConfig
from wuttjamaican.util import UNSPECIFIED
@ -315,6 +316,19 @@ class TestAppHandler(TestCase):
uuid = self.app.make_uuid()
self.assertEqual(len(uuid), 32)
def test_progress_loop(self):
def act(obj, i):
pass
# with progress
self.app.progress_loop(act, [1, 2, 3], ProgressBase,
message="whatever")
# without progress
self.app.progress_loop(act, [1, 2, 3], None,
message="whatever")
def test_get_session(self):
try:
import sqlalchemy as sa

27
tests/test_progress.py Normal file
View file

@ -0,0 +1,27 @@
# -*- coding: utf-8; -*-
from unittest import TestCase
from wuttjamaican import progress as mod
class TestProgressBase(TestCase):
def test_basic(self):
# sanity / coverage check
prog = mod.ProgressBase('testing', 2)
prog.update(1)
prog.update(2)
prog.finish()
class TestConsoleProgress(TestCase):
def test_basic(self):
# sanity / coverage check
prog = mod.ConsoleProgress('testing', 2)
prog.update(1)
prog.update(2)
prog.finish()

View file

@ -7,6 +7,7 @@ from unittest.mock import patch, MagicMock
import pytest
from wuttjamaican import util as mod
from wuttjamaican.progress import ProgressBase
class A: pass
@ -260,3 +261,19 @@ class TestMakeTitle(TestCase):
def test_basic(self):
text = mod.make_title('foo_bar')
self.assertEqual(text, "Foo Bar")
class TestProgressLoop(TestCase):
def test_basic(self):
def act(obj, i):
pass
# with progress
mod.progress_loop(act, [1, 2, 3], ProgressBase,
message="whatever")
# without progress
mod.progress_loop(act, [1, 2, 3], None,
message="whatever")