Socialify

Folder ..

Viewing test_zip.py
34 lines (24 loc) • 796.0 B

 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
from edify.library import zip


def test_valid_zips():
    zips = {"12345": True, "12345-1234": True, "12345-123456": False, "1234": False}
    for zip_string, expectation in zips.items():
        assert zip(zip_string) == expectation


def test_invalid_locale():
    try:
        zip("12345", locale="INVALID")
    except ValueError:
        assert True


def test_invalid_locale_type():
    try:
        zip("12345", 5)
    except TypeError:
        assert True


def test_empty_locale():
    try:
        zip("12345", "")
    except ValueError:
        assert True


def test_locale_IN():
    zips = {"123456": True, "000000": False, "012345": False, "12345": False, "1234567": False}
    for zip_string, expectation in zips.items():
        assert zip(zip_string, locale="IN") == expectation