-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathtest_finance.py
More file actions
69 lines (50 loc) · 1.84 KB
/
Copy pathtest_finance.py
File metadata and controls
69 lines (50 loc) · 1.84 KB
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
"""Test Finance."""
# external
import pytest
# local
from validators import ValidationError, cusip, isin, sedol
# ==> CUSIP <== #
@pytest.mark.parametrize("value", ["912796X38", "912796X20", "912796x20"])
def test_returns_true_on_valid_cusip(value: str):
"""Test returns true on valid cusip."""
assert cusip(value)
@pytest.mark.parametrize("value", ["912796T67", "912796T68", "XCVF", "00^^^1234"])
def test_returns_failed_validation_on_invalid_cusip(value: str):
"""Test returns failed validation on invalid cusip."""
assert isinstance(cusip(value), ValidationError)
# ==> ISIN <== #
@pytest.mark.parametrize(
"value",
["US0004026250", "JP000K0VF055", "US0378331005", "AU0000XVGZA3", "GB0002634946"],
)
def test_returns_true_on_valid_isin(value: str):
"""Test returns true on valid isin."""
assert isin(value)
@pytest.mark.parametrize(
"value",
[
"010378331005",
"XCVF",
"00^^^1234",
"A000009",
# valid format but incorrect check digit (previously accepted, see gh-440)
"US0378331004",
"GB0002634947",
"AU0000XVGZA4",
"JP000K0VF054",
# lowercase country code is not a valid ISIN
"us0378331005",
],
)
def test_returns_failed_validation_on_invalid_isin(value: str):
"""Test returns failed validation on invalid isin."""
assert isinstance(isin(value), ValidationError)
# ==> SEDOL <== #
@pytest.mark.parametrize("value", ["0263494", "0540528", "B000009"])
def test_returns_true_on_valid_sedol(value: str):
"""Test returns true on valid sedol."""
assert sedol(value)
@pytest.mark.parametrize("value", ["0540526", "XCVF", "00^^^1234", "A000009"])
def test_returns_failed_validation_on_invalid_sedol(value: str):
"""Test returns failed validation on invalid sedol."""
assert isinstance(sedol(value), ValidationError)