Keep dependency installs responsive
This commit is contained in:
@@ -18,6 +18,29 @@ class FakeWidget:
|
||||
self.seen = index
|
||||
|
||||
|
||||
class FakeLogWidget:
|
||||
def __init__(self):
|
||||
self.value = ""
|
||||
self.insert_calls = 0
|
||||
|
||||
def configure(self, **options):
|
||||
pass
|
||||
|
||||
def insert(self, index, value):
|
||||
self.insert_calls += 1
|
||||
self.value += value
|
||||
|
||||
def index(self, index):
|
||||
return f"{self.value.count(chr(10)) + 1}.0"
|
||||
|
||||
def delete(self, start, end):
|
||||
delete_lines = max(int(end.split('.', 1)[0]) - 1, 0)
|
||||
self.value = "\n".join(self.value.split("\n")[delete_lines:])
|
||||
|
||||
def see(self, index):
|
||||
pass
|
||||
|
||||
|
||||
class FakeButton:
|
||||
def __init__(self):
|
||||
self.state = None
|
||||
@@ -35,6 +58,22 @@ class FakeVariable:
|
||||
|
||||
|
||||
class GuiNavigationTests(unittest.TestCase):
|
||||
def test_log_queue_is_rendered_in_batches(self):
|
||||
app = DeployWorkbench.__new__(DeployWorkbench)
|
||||
app.ui_queue = queue.Queue()
|
||||
app.log_text = FakeLogWidget()
|
||||
scheduled = []
|
||||
app.after = lambda delay, callback: scheduled.append(delay)
|
||||
for index in range(100):
|
||||
app.ui_queue.put(("log", f"line {index}"))
|
||||
|
||||
DeployWorkbench._drain_queue(app)
|
||||
|
||||
self.assertEqual(app.log_text.insert_calls, 1)
|
||||
self.assertIn("line 0", app.log_text.value)
|
||||
self.assertIn("line 99", app.log_text.value)
|
||||
self.assertEqual(scheduled, [120])
|
||||
|
||||
def test_database_name_comes_from_first_sql_filename(self):
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
Reference in New Issue
Block a user