import unittest
from pyplanetarium import Window
class WindowCase(unittest.TestCase):
def test_init(self) -> None:
wnd = Window(((100, 200), (128, 64)))
self.assertIsInstance(wnd, Window)
self.assertEqual(str(wnd), "(100, 200)+(128, 64)")
self.assertEqual(
repr(wnd),
"Window { x: 100, y: 200, w: 128, h: 64 }",
)
def test_new_at(self) -> None:
wnd1 = Window.new(128, 64)
self.assertIsInstance(wnd1, Window)
self.assertEqual(str(wnd1), "(0, 0)+(128, 64)")
self.assertEqual(
repr(wnd1),
"Window { x: 0, y: 0, w: 128, h: 64 }",
)
wnd2 = wnd1.at(100, 200)
self.assertIsInstance(wnd2, Window)
self.assertEqual(str(wnd2), "(100, 200)+(128, 64)")
self.assertEqual(
repr(wnd2),
"Window { x: 100, y: 200, w: 128, h: 64 }",
)
def test_init_err(self) -> None:
with self.assertRaises(TypeError):
Window()
with self.assertRaises(TypeError):
Window(10, 20)
if __name__ == "__main__":
unittest.main()