-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1185097
commit 65b87b6
Showing
32 changed files
with
2,915 additions
and
38 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
docs/html/_downloads/be264a7a365b1d3baf51a092ce84efc9/test_network_clients.py
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,66 @@ | ||
import os | ||
from unittest import mock | ||
|
||
from algokit_utils import ( | ||
get_algod_client, | ||
get_algonode_config, | ||
get_default_localnet_config, | ||
get_indexer_client, | ||
get_purestake_config, | ||
) | ||
|
||
DEFAULT_TOKEN = "a" * 64 | ||
|
||
|
||
def test_localnet_algod() -> None: | ||
algod_client = get_algod_client(get_default_localnet_config("algod")) | ||
health_response = algod_client.health() | ||
assert health_response is None | ||
|
||
|
||
def test_localnet_indexer() -> None: | ||
indexer_client = get_indexer_client(get_default_localnet_config("indexer")) | ||
health_response = indexer_client.health() # type: ignore[no-untyped-call] | ||
assert isinstance(health_response, dict) | ||
|
||
|
||
def test_purestake_headers() -> None: | ||
algod_client = get_algod_client(get_purestake_config("testnet", "algod", DEFAULT_TOKEN)) | ||
indexer_client = get_indexer_client(get_purestake_config("testnet", "indexer", DEFAULT_TOKEN)) | ||
|
||
assert algod_client.headers == {"X-API-Key": DEFAULT_TOKEN} | ||
assert indexer_client.headers == {"X-API-Key": DEFAULT_TOKEN} | ||
|
||
|
||
def test_purestake_address() -> None: | ||
algod_client = get_algod_client(get_purestake_config("testnet", "algod", DEFAULT_TOKEN)) | ||
indexer_client = get_indexer_client(get_purestake_config("testnet", "indexer", DEFAULT_TOKEN)) | ||
|
||
assert algod_client.algod_address == "https://testnet-algorand.api.purestake.io/ps2" | ||
assert indexer_client.indexer_address == "https://testnet-algorand.api.purestake.io/idx2" | ||
|
||
|
||
@mock.patch.dict( | ||
os.environ, | ||
{ | ||
"ALGOD_SERVER": "https://testnet-algorand.api.purestake.io/ps2", | ||
"ALGOD_PORT": "443", | ||
"ALGOD_TOKEN": DEFAULT_TOKEN, | ||
}, | ||
) | ||
def test_environment_config() -> None: | ||
algod_client = get_algod_client() | ||
|
||
assert algod_client.algod_address == "https://testnet-algorand.api.purestake.io:443/ps2" | ||
|
||
|
||
def test_cloudnode_algod_headers() -> None: | ||
algod_client = get_algod_client(get_algonode_config("testnet", "algod", DEFAULT_TOKEN)) | ||
|
||
assert algod_client.headers == {"X-Algo-API-Token": DEFAULT_TOKEN} | ||
|
||
|
||
def test_cloudnode_indexer_headers() -> None: | ||
indexer_client = get_indexer_client(get_algonode_config("testnet", "indexer", DEFAULT_TOKEN)) | ||
|
||
assert indexer_client.headers == {"X-Indexer-API-Token": DEFAULT_TOKEN} |
Oops, something went wrong.