-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_discount.py
78 lines (71 loc) · 1.99 KB
/
test_discount.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
72
73
74
75
76
77
78
# pylint: disable=missing-module-docstring, missing-function-docstring
import pandas as pd
import pytest
from xil._currencies import CurrencyCode
from xil.discount import get_discount_df
@pytest.fixture(name="df")
def df_fixture() -> pd.DataFrame:
return get_discount_df()
@pytest.fixture(name="currencies")
def currencies_fixture() -> set[CurrencyCode]:
return {
CurrencyCode.EUR,
CurrencyCode.ETB,
CurrencyCode.LKR,
CurrencyCode.NGN,
CurrencyCode.KRW,
CurrencyCode.BGN,
CurrencyCode.AUD,
CurrencyCode.CHF,
CurrencyCode.CNY,
CurrencyCode.GBP,
CurrencyCode.MXN,
CurrencyCode.EGP,
CurrencyCode.SAR,
CurrencyCode.HUF,
CurrencyCode.CAD,
CurrencyCode.HKD,
CurrencyCode.INR,
CurrencyCode.PEN,
CurrencyCode.USD,
CurrencyCode.XPD,
CurrencyCode.IDR,
CurrencyCode.RUB,
CurrencyCode.TRY,
CurrencyCode.XPT,
CurrencyCode.SEK,
CurrencyCode.TWD,
CurrencyCode.HRK,
CurrencyCode.NOK,
CurrencyCode.SAL,
CurrencyCode.THB,
CurrencyCode.SGD,
CurrencyCode.CZK,
CurrencyCode.PHP,
CurrencyCode.NZD,
CurrencyCode.XAU,
CurrencyCode.LBP,
CurrencyCode.PLN,
CurrencyCode.XAG,
CurrencyCode.BRL,
CurrencyCode.CLP,
CurrencyCode.JPY,
CurrencyCode.ZAR,
CurrencyCode.ARS,
CurrencyCode.DKK,
CurrencyCode.JOD,
CurrencyCode.RON,
}
@pytest.mark.parametrize(
"dropped_currencies", [[CurrencyCode.XAU, CurrencyCode.NGN]]
) # There's an issue with Gold
@pytest.mark.live
def test_df(
df: pd.DataFrame,
currencies: set[CurrencyCode],
dropped_currencies: list[CurrencyCode],
) -> None:
assert set(df.index) == currencies
df = df.drop(index=dropped_currencies)
for method in ("cash", "transfer"):
assert (df[(method, "sell")] >= df[(method, "buy")]).all()