fix integration tests

This commit is contained in:
Pablo Martin 2024-06-27 17:42:10 +02:00
parent 0db434ee5b
commit 236fb39f28

View file

@ -11,8 +11,8 @@ from xexe.constants import DEFAULT_CURRENCIES
def test_get_rates_for_hardcoded_case_returns_expected_output():
"""
Calling the CLI get-rates command to get the rates between USD, EUR and GBP
for 2024-01-01 to 2024-01-03 returns the expected records in a CSV.
Calling the CLI get-rates command to get the rates between CAD and GBP for
2024-06-20 returns the expected records in a CSV.
ATTENTION!
@ -27,7 +27,7 @@ def test_get_rates_for_hardcoded_case_returns_expected_output():
runs.
"""
""" # Unstring this to activate test
""" # Unstring this to activate test
runner = CliRunner()
with runner.isolated_filesystem():
@ -35,11 +35,11 @@ def test_get_rates_for_hardcoded_case_returns_expected_output():
get_rates,
[
"--start-date",
"2024-01-01",
"2024-06-20",
"--end-date",
"2024-01-02",
"2024-06-20",
"--currencies",
"USD,GBP",
"CAD,EUR",
"--rates-source",
"xe",
"--output",
@ -49,11 +49,30 @@ def test_get_rates_for_hardcoded_case_returns_expected_output():
assert run_result.exit_code == 0
# Write code here to read output file and compare it against expected
# output
assert False
"""
expected_output = [
["from_currency", "to_currency", "rate", "rate_date", "exported_at"],
["CAD", "EUR", "0.67884137", "2024-06-20", "2024-06-27T17:26:04"],
["EUR", "CAD", "1.47309820", "2024-06-20", "2024-06-27T17:26:04"],
["CAD", "CAD", "1.00000000", "2024-06-20", "2024-06-27T17:26:04"],
["EUR", "EUR", "1.00000000", "2024-06-20", "2024-06-27T17:26:04"],
]
with open("test_output.csv", newline="") as csvfile:
reader = csv.reader(csvfile)
output = list(reader)
headers_match = output[0] == expected_output[0]
assert headers_match
for i, row in enumerate(output[1:], start=1):
row_matches = row[:4] == expected_output[i][:4]
exported_at_is_valid_iso_datetime = bool(
datetime.datetime.fromisoformat(row[4])
)
assert row_matches and exported_at_is_valid_iso_datetime
"""
# This is for when the main test is commented out
assert True