import sys
import unittest

from zeitfenster import im_wartungsfenster


class Tests(unittest.TestCase):
    def test_im_fenster(self):
        for h in (23, 0, 1, 2, 3, 4):
            self.assertTrue(im_wartungsfenster(h), f"Stunde {h}")

    def test_ausserhalb(self):
        for h in (5, 6, 12, 18, 22):
            self.assertFalse(im_wartungsfenster(h), f"Stunde {h}")

    def test_ungueltig(self):
        for h in (-1, 24, 99):
            with self.assertRaises(ValueError):
                im_wartungsfenster(h)


if __name__ == "__main__":
    r = unittest.main(exit=False).result
    sys.exit(0 if r.wasSuccessful() else 1)
