activate environment again in test
This commit is contained in:
parent
515a4527af
commit
aa0919c790
1 changed files with 43 additions and 43 deletions
|
|
@ -78,50 +78,50 @@ def test_get_rates_dry_run_always_returns_42_as_rates():
|
|||
|
||||
runner = CliRunner()
|
||||
|
||||
# with runner.isolated_filesystem():
|
||||
run_result = runner.invoke(
|
||||
get_rates,
|
||||
[
|
||||
"--start-date",
|
||||
some_random_date.strftime("%Y-%m-%d"),
|
||||
"--end-date",
|
||||
(some_random_date + datetime.timedelta(days=3)).strftime("%Y-%m-%d"),
|
||||
"--currencies",
|
||||
",".join(some_random_currencies),
|
||||
"--output",
|
||||
"test_output.csv",
|
||||
],
|
||||
)
|
||||
with runner.isolated_filesystem():
|
||||
run_result = runner.invoke(
|
||||
get_rates,
|
||||
[
|
||||
"--start-date",
|
||||
some_random_date.strftime("%Y-%m-%d"),
|
||||
"--end-date",
|
||||
(some_random_date + datetime.timedelta(days=3)).strftime("%Y-%m-%d"),
|
||||
"--currencies",
|
||||
",".join(some_random_currencies),
|
||||
"--output",
|
||||
"test_output.csv",
|
||||
],
|
||||
)
|
||||
|
||||
assert run_result.exit_code == 0
|
||||
assert run_result.exit_code == 0
|
||||
|
||||
with open("test_output.csv", newline="") as csv_file:
|
||||
reader = csv.DictReader(csv_file)
|
||||
rows = list(reader)
|
||||
|
||||
# Ensure that the output contains the correct number of rows
|
||||
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, 1/42 or 1 and the correct dates
|
||||
for row in rows:
|
||||
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)
|
||||
], f"Unexpected rate_date {row['rate_date']}"
|
||||
with open("test_output.csv", newline="") as csv_file:
|
||||
reader = csv.DictReader(csv_file)
|
||||
rows = list(reader)
|
||||
|
||||
# Ensure that the output contains the correct number of rows
|
||||
expected_num_rows = 36
|
||||
assert (
|
||||
row["from_currency"] in some_random_currencies
|
||||
), f"Unexpected from_currency {row['from_currency']}"
|
||||
assert (
|
||||
row["to_currency"] in some_random_currencies
|
||||
), f"Unexpected to_currency {row['to_currency']}"
|
||||
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, 1/42 or 1 and the correct dates
|
||||
for row in rows:
|
||||
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)
|
||||
], f"Unexpected rate_date {row['rate_date']}"
|
||||
|
||||
assert (
|
||||
row["from_currency"] in some_random_currencies
|
||||
), f"Unexpected from_currency {row['from_currency']}"
|
||||
assert (
|
||||
row["to_currency"] in some_random_currencies
|
||||
), f"Unexpected to_currency {row['to_currency']}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue