From 632b8e5066bb6a6a511aa9ed6dee4ce7990833d8 Mon Sep 17 00:00:00 2001 From: Rohan Agarwal Date: Thu, 21 Nov 2024 16:58:20 -0500 Subject: [PATCH] Fix --- cdp/asset.py | 2 +- tests/test_asset.py | 2 ++ tests/test_balance.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cdp/asset.py b/cdp/asset.py index c3857f6..d03a35d 100644 --- a/cdp/asset.py +++ b/cdp/asset.py @@ -52,7 +52,7 @@ def from_model(cls, model: AssetModel, asset_id: str | None = None) -> "Asset": return cls( network_id=model.network_id, - asset_id=model.asset_id, + asset_id=asset_id or model.asset_id, contract_address=model.contract_address, decimals=decimals, ) diff --git a/tests/test_asset.py b/tests/test_asset.py index 3b36338..2cea01b 100644 --- a/tests/test_asset.py +++ b/tests/test_asset.py @@ -32,6 +32,7 @@ def test_asset_from_model_with_gwei(asset_model_factory): asset_model = asset_model_factory(asset_id="eth", decimals=18) asset = Asset.from_model(asset_model, asset_id="gwei") + assert asset.asset_id == "gwei" assert asset.decimals == 9 @@ -40,6 +41,7 @@ def test_asset_from_model_with_wei(asset_model_factory): asset_model = asset_model_factory(asset_id="eth", decimals=18) asset = Asset.from_model(asset_model, asset_id="wei") + assert asset.asset_id == "wei" assert asset.decimals == 0 diff --git a/tests/test_balance.py b/tests/test_balance.py index 3f4f691..53303c9 100644 --- a/tests/test_balance.py +++ b/tests/test_balance.py @@ -42,7 +42,7 @@ def test_balance_from_model_with_asset_id(balance_model_factory): balance = Balance.from_model(balance_model, asset_id="gwei") assert balance.amount == Decimal("1000000000") assert isinstance(balance.asset, Asset) - assert balance.asset.asset_id == "eth" + assert balance.asset.asset_id == "gwei" assert balance.asset_id == "gwei"