forked from benevolentprof/inf1340_2015_asst3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_exercise2.py
71 lines (55 loc) · 1.88 KB
/
test_exercise2.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
# imports one per line
import os
from exercise2 import decide
""" Module to test papers.py """
__author__ = 'Mib_Oli_Par'
DIR = "test_jsons/"
os.chdir(DIR)
def test_returning():
"""
Travellers are returning to KAN.
"""
assert decide("test_returning_citizen.json", "countries.json") ==\
["Accept", "Accept", "Quarantine"]
def test_unknown_location():
"""
Travellers with unknown location
#1 Both the locations are unknown - home & from
#2 Only one location is unknown
:return:
"""
assert decide("unknown_location.json", "countries.json") ==\
["Reject", "Reject"]
def test_visa_validity():
"""
Travellers requiring Visa will need a validity check
#1 Traveller requires valid visa
#2 Invalid date format
#3 Invalid visa code format
#4 Traveler requires a visa but his validity is over
"""
assert decide("visa_validity.json", "countries.json") ==\
["Accept", "Reject", "Reject", "Reject"]
def test_medical_advisory():
"""
Test for travelers traveling from
countries having medical advisories
#1 Traveler belonging to Kanadia but
traveling from a country having medical advisory
#2 Traveler from some other country,
traveling from a country having medical advisory
"""
assert decide("medical_advisory.json", "countries.json") ==\
["Quarantine", "Quarantine"]
def test_miscellaneous():
"""
Tests for some minor details in traveler's data
#1 Whether all the required fields are provided or nor (last name missing)
#2 Lowercase passport numbers
#3 Lowercase country code
#4 Whether the passport number is in correct format
#5 If the traveler is traveling via a country having medical advisory
"""
assert decide("miscellaneous.json", "countries.json") ==\
["Reject", "Accept", "Accept", "Reject", "Quarantine"]