improve test to exclude weird currencies we don't use
This commit is contained in:
parent
b9e4892c5d
commit
6b12078478
1 changed files with 11 additions and 6 deletions
|
|
@ -6,6 +6,7 @@ from click.testing import CliRunner
|
|||
from money.currency import Currency
|
||||
|
||||
from xexe.cli import get_rates
|
||||
from xexe.constants import DEFAULT_CURRENCIES
|
||||
|
||||
|
||||
def test_get_rates_for_hardcoded_case_returns_expected_output():
|
||||
|
|
@ -70,7 +71,7 @@ def test_get_rates_dry_run_always_returns_42_as_rates():
|
|||
|
||||
some_random_currencies = [
|
||||
some_currency.value
|
||||
for some_currency in random.sample(population=list(Currency), k=3)
|
||||
for some_currency in random.sample(population=list(DEFAULT_CURRENCIES), k=3)
|
||||
]
|
||||
|
||||
runner = CliRunner()
|
||||
|
|
@ -98,16 +99,20 @@ def test_get_rates_dry_run_always_returns_42_as_rates():
|
|||
rows = list(reader)
|
||||
|
||||
# Ensure that the output contains the correct number of rows
|
||||
expected_num_rows = (3 + 1) * len(
|
||||
some_random_currencies
|
||||
) # 3 days + 1 day = 4 dates for each currency
|
||||
expected_num_rows = 36
|
||||
assert (
|
||||
len(rows) == expected_num_rows
|
||||
), f"Expected {expected_num_rows} rows, but got {len(rows)}"
|
||||
|
||||
# Check that all rows have the expected rate of 42 and the correct dates
|
||||
# Check that all rows have the expected rate of 42, 1/42 or 1 and the correct dates
|
||||
for row in rows:
|
||||
assert row["rate"] == "42", f"Expected rate to be 42, but got {row['rate']}"
|
||||
assert row["rate"] in (
|
||||
"42",
|
||||
"0.024",
|
||||
"0.02",
|
||||
"0",
|
||||
"1",
|
||||
), f"Expected rate to be 42, 1/42 or 1, but got {row['rate']}"
|
||||
assert row["rate_date"] in [
|
||||
(some_random_date + datetime.timedelta(days=i)).strftime("%Y-%m-%d")
|
||||
for i in range(4)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue