-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feature: get_program_price functions * Fix: add also to abstract AlehpClient * Fix: black issue * Fix: add superfuild to pyproject.toml * Revert "Fix: add superfuild to pyproject.toml" This reverts commit d206c0c. * Fix: isort issue * Fix: type * Fix: unit test * Fix: style issue * Update src/aleph/sdk/client/http.py Co-authored-by: Hugo Herter <[email protected]> --------- Co-authored-by: Hugo Herter <[email protected]>
- Loading branch information
Showing
6 changed files
with
101 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
|
||
from aleph.sdk.exceptions import InvalidHashError | ||
from aleph.sdk.query.responses import PriceResponse | ||
from tests.unit.conftest import make_mock_get_session, make_mock_get_session_400 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_get_program_price_valid(): | ||
""" | ||
Test that the get_program_price method returns the correct PriceResponse | ||
when given a valid item hash. | ||
""" | ||
expected_response = { | ||
"required_tokens": 3.0555555555555556e-06, | ||
"payment_type": "superfluid", | ||
} | ||
mock_session = make_mock_get_session(expected_response) | ||
async with mock_session: | ||
response = await mock_session.get_program_price("cacacacacacaca") | ||
assert response == PriceResponse(**expected_response) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_get_program_price_invalid(): | ||
""" | ||
Test that the get_program_price method raises an InvalidHashError | ||
when given an invalid item hash. | ||
""" | ||
mock_session = make_mock_get_session_400({"error": "Invalid hash"}) | ||
async with mock_session: | ||
with pytest.raises(InvalidHashError): | ||
await mock_session.get_program_price("invalid_item_hash") |