update
This commit is contained in:
@@ -276,6 +276,44 @@ class TestBibliothekSystem(unittest.TestCase):
|
||||
).fetchone()
|
||||
self.assertIsNotNone(row)
|
||||
|
||||
def test_center_tool_window_helper(self):
|
||||
import tkinter as tk
|
||||
from aza_ui_helpers import center_tool_window
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
win = tk.Toplevel(root)
|
||||
win.geometry("400x300")
|
||||
center_tool_window(win, 400, 300, y_ratio=0.08, bring_to_front=False)
|
||||
parts = win.geometry().split("+")
|
||||
self.assertEqual(len(parts), 3)
|
||||
x, y = int(parts[1]), int(parts[2])
|
||||
sw, sh = win.winfo_screenwidth(), win.winfo_screenheight()
|
||||
self.assertGreaterEqual(x, 0)
|
||||
self.assertLessEqual(x, max(0, sw - 400))
|
||||
self.assertGreaterEqual(y, 0)
|
||||
self.assertLessEqual(y, max(0, int(sh * 0.12)))
|
||||
win.destroy()
|
||||
root.destroy()
|
||||
|
||||
def test_bibliothek_add_dialog_new_buttons(self):
|
||||
path = os.path.join(os.path.dirname(__file__), "basis14.py")
|
||||
with open(path, encoding="utf-8") as fh:
|
||||
src = fh.read()
|
||||
block = src.split("def _show_bibliothek_add_dialog", 1)[-1].split("\n def ", 1)[0]
|
||||
self.assertIn("Öffentliche Bibliothek", block)
|
||||
self.assertIn("Eigene Bibliothek", block)
|
||||
self.assertIn("Schließen", block)
|
||||
self.assertIn("center_tool_window", block)
|
||||
self.assertNotIn("Zur Bibliothek hinzufuegen", block)
|
||||
self.assertNotIn("Nicht hinzufuegen", block)
|
||||
|
||||
def test_center_tool_window_in_ui_helpers(self):
|
||||
path = os.path.join(os.path.dirname(__file__), "aza_ui_helpers.py")
|
||||
with open(path, encoding="utf-8") as fh:
|
||||
src = fh.read()
|
||||
self.assertIn("def center_tool_window", src)
|
||||
self.assertIn("def bring_tool_window_to_front", src)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user