-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from macxred/feat/implement-price-price-history
Feat: create get_exchange_rate() method and tests for it
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Unit tests for currencies.""" | ||
|
||
from cashctrl_api import CashCtrlClient | ||
import pytest | ||
|
||
|
||
def test_exchange_rate(): | ||
cc_client = CashCtrlClient() | ||
|
||
exchange_rate = cc_client.get_exchange_rate("USD", "CHF") | ||
assert isinstance(exchange_rate, float), "`exchange_rate` is not a Float." | ||
|
||
# Exchange rate for invalid currency should raise an error | ||
with pytest.raises(Exception): | ||
cc_client.get_exchange_rate("USD", "INVALID") | ||
|
||
exchange_rate = cc_client.get_exchange_rate("USD", "USD") | ||
assert exchange_rate == 1, "Exchange rate for the same currency should be 1." | ||
|
||
exchange_rate = cc_client.get_exchange_rate("USD", "CHF", '2020-01-15') | ||
assert exchange_rate == 0.967145, "Exchange rate for USD-CHF on 2020-01-15 should be 0.967145." |