forked from CarmineOptions/derisk-research
-
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 CarmineOptions#342 from AdejareSamad/feat/create-g…
…et-protocol-interface feat: create new interface for get_protocols
- Loading branch information
Showing
9 changed files
with
63 additions
and
12 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,43 @@ | ||
import pytest | ||
from shared.state import State | ||
|
||
|
||
class MockLoanEntity: | ||
"""Mock loan entity for testing""" | ||
pass | ||
|
||
|
||
class MockState(State): | ||
def __init__(self): | ||
super().__init__(loan_entity_class=MockLoanEntity) | ||
|
||
def compute_liquidable_debt_at_price(self, *args, **kwargs): | ||
return None | ||
|
||
|
||
def test_state_without_protocol_name(): | ||
"""Test that accessing get_protocol_name raises NotImplementedError when PROTOCOL_NAME is not set""" | ||
mock_state = MockState() | ||
with pytest.raises(NotImplementedError): | ||
_ = mock_state.get_protocol_name | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"protocol_name", | ||
["zkLend", "Nostra Alpha", "Nostra Mainnet"] | ||
) | ||
def test_protocol_names(protocol_name): | ||
"""Test that protocol name is correctly returned""" | ||
mock_state = MockState() | ||
mock_state.PROTOCOL_NAME = protocol_name | ||
assert mock_state.get_protocol_name == protocol_name | ||
|
||
|
||
def test_get_protocol_helper(): | ||
"""Test the get_protocol helper function""" | ||
from dashboard_app.helpers.loans_table import get_protocol | ||
|
||
mock_state = MockState() | ||
mock_state.PROTOCOL_NAME = "Test Protocol" | ||
assert get_protocol(mock_state) == "Test Protocol" | ||
|
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
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
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
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