<commit_before>#!/usr/bin/env python3

""" Module to test papers.py  """

__author__ = '<NAME>'
__email__ = "<EMAIL>"

__copyright__ = "2014 <NAME>"
__license__ = "MIT License"

__status__ = "Prototype"

"""
This program is used to test each functions in "papers.py".
For the decide() function, we added extra tests for it:
1. If the reason for entry is to visit and the visitor has a passport from a country from which a visitor
visa is required, the traveller must have a valid visa.
2. If the reason for entry is transit and the visitor has a passport from a country from which a transit
visa is required, the traveller must have a valid visa.
3. If the person only has last name and first name on watchlist without passport number on watchlist.
4. If the person did not come from the country with medical advisory but went via the country with medical advisory.
Additionally, we added the test cases for the functions valid_passport_format() and valid_date_format();
"""
# imports one per line
import papers
from papers import decide
from papers import valid_date_format
from papers import valid_passport_format


def test_basic():
    assert decide("test_returning_citizen.json", "watchlist.json", "countries.json") == ["Accept", "Accept"]
    assert decide("test_watchlist.json", "watchlist.json", "countries.json") == ["Secondary"]
    assert decide("test_quarantine.json", "watchlist.json", "countries.json") == ["Quarantine"]


def test_files():
    FileNotFoundError = IOError
    with papers.raises(FileNotFoundError):
        decide("test_returning_citizen.json", "", "countries.json")

# Determines if visitor who come from a country which needs visa if his visa is invalid.
def test_visa_valid():
    assert decide("test_vistor_visa_expired.json", "watchlist.json", "countries.json") == ["Reject"]
    # Came from CFR (this country needs visitor visa)
    assert decide("test_transit_visa_expired.json", "watchlist.json", "countries.json") == ["Reject"]
    # Came from LUG (I personally changed the visitor_visa_required for LUG to 0 for convenient test)

# Test to reject the person who only have last name and first name on watchlist without passport number on watchlist.
def test_secondary():
    assert decide("test_secondary.json", "watchlist.json", "countries.json") == ["Secondary"]<commit_msg>#Tiny correnctions<commit_after>#!/usr/bin/env python3

""" Module to test papers.py  """

__author__ = '<NAME>'
__email__ = "<EMAIL>"

__copyright__ = "2014 <NAME>"
__license__ = "MIT License"

__status__ = "Prototype"

"""
This program is used to test each functions in "papers.py".
For the decide() function, we added extra tests for it:
1. If the reason for entry is to visit and the visitor has a passport from a country from which a visitor
visa is required, the traveller must have a valid visa.
2. If the reason for entry is transit and the visitor has a passport from a country from which a transit
visa is required, the traveller must have a valid visa.
3. If the person only has last name and first name on watchlist without passport number on watchlist.
4. If the person did not come from the country with medical advisory but went via the country with medical advisory.
Additionally, we added the test cases for the functions valid_passport_format() and valid_date_format();
"""
# imports one per line
import papers
from papers import decide
from papers import valid_date_format
from papers import valid_passport_format


def test_basic():
    assert decide("test_returning_citizen.json", "watchlist.json", "countries.json") == ["Accept", "Accept"]
    assert decide("test_watchlist.json", "watchlist.json", "countries.json") == ["Secondary"]
    assert decide("test_quarantine.json", "watchlist.json", "countries.json") == ["Quarantine"]


def test_files():
    FileNotFoundError = IOError # Raises FileNotFoundError if there is IO error.
    with papers.raises(FileNotFoundError):
        decide("test_returning_citizen.json", "", "countries.json")

# Determines if visitor who come from a country which needs visa if his visa is invalid.
def test_visa_valid():
    assert decide("test_vistor_visa_expired.json", "watchlist.json", "countries.json") == ["Reject"]
    # Came from CFR (this country needs visitor visa)
    assert decide("test_transit_visa_expired.json", "watchlist.json", "countries.json") == ["Reject"]
    # Came from LUG (I personally changed the visitor_visa_required for LUG to 0 for convenient test)

# Test to reject the person who only have last name and first name on watchlist without passport number on watchlist.
def test_secondary():
    assert decide("test_secondary.json", "watchlist.json", "countries.json") == ["Secondary"]
{'fraction_non_alphanumeric': 0.0958173282116944, 'fraction_numerical': 0.004268032437046522, 'mean_word_length': 4.895597484276729, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3572160', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1303, 'n_words': 555}