From aa0919c79014bd96da038ae78d21dee98915d6a6 Mon Sep 17 00:00:00 2001 From: Pablo Martin Date: Thu, 13 Jun 2024 15:59:03 +0200 Subject: [PATCH] activate environment again in test --- tests/tests_integration/test_get_rates.py | 86 +++++++++++------------ 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/tests/tests_integration/test_get_rates.py b/tests/tests_integration/test_get_rates.py index a3a59cc..c41ec72 100644 --- a/tests/tests_integration/test_get_rates.py +++ b/tests/tests_integration/test_get_rates.py @@ -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']}"