-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_schengen.py
28 lines (22 loc) · 968 Bytes
/
test_schengen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import unittest
from datetime import date
from schengen import Visa, VisaError, OverstayWarning
class TestVisa(unittest.TestCase):
def test_overstay(self):
visa = Visa(date(2020, 1, 1), date(2021, 1, 1))
visa.add_trip(date(2020, 1, 1), date(2020, 2, 1))
with self.assertRaises(VisaError):
visa.add_trip(date(2020, 3, 1), date(2020, 5, 1))
with self.assertWarns(OverstayWarning):
visa.add_trip(date(2020, 3, 1), date(2020, 5, 1), False)
self.assertFalse(visa.valid)
def test_max_stay(self):
visa = Visa(date(2020, 1, 1), date(2021, 1, 1))
visa.add_trip(date(2020, 1, 1), date(2020, 2, 1))
visa.add_trip(date(2020, 3, 1), date(2020, 4, 27))
visa.add_trip(date(2020, 6, 29), date(2020, 7, 30))
self.assertTrue(visa.valid)
if __name__ == "__main__":
import warnings
warnings.simplefilter("ignore")
unittest.main()