Skip to content

Commit

Permalink
add markers for network interaction tests
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed Mar 6, 2024
1 parent 10330c9 commit f5293ee
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ If using VSCode, restart it or follow these steps:

Run the tests as follows:

This command runs all tests:
```
pytest .
```

If you want to skip network interaction tests run:
```
pytest -m "not networkInteraction"
```
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def get_size(self) -> int:
return self.size


@pytest.mark.networkInteraction
class TestApi:
api = ApiNetworkProvider('https://devnet-api.multiversx.com')

Expand Down Expand Up @@ -133,7 +134,7 @@ def test_get_transactions_in_mempool_for_account(self):
def test_get_sc_invoking_tx(self):
result = self.api.get_transaction('6fe05e4ca01d42c96ae5182978a77fe49f26bcc14aac95ad4f19618173f86ddb')

assert result.is_completed == True
assert result.is_completed is True
assert len(result.contract_results.items) > 0
assert result.data == 'issue@54455354546f6b656e@54455354@016345785d8a0000@06@63616e4368616e67654f776e6572@74727565@63616e55706772616465@74727565@63616e4164645370656369616c526f6c6573@74727565'

Expand Down
37 changes: 11 additions & 26 deletions multiversx_sdk/network_providers/proxy_network_provider_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import pytest

from multiversx_sdk.core.address import Address
from multiversx_sdk.core.transaction import Transaction
from multiversx_sdk.network_providers.proxy_network_provider import (
ContractQuery, ProxyNetworkProvider)


@pytest.mark.networkInteraction
class TestProxy:
proxy = ProxyNetworkProvider("https://devnet-gateway.multiversx.com")

Expand Down Expand Up @@ -47,10 +50,7 @@ def test_get_account(self):
)
result = self.proxy.get_account(address)

assert (
result.address.to_bech32()
== "erd1487vz5m4zpxjyqw4flwa3xhnkzg4yrr3mkzf5sf0zgt94hjprc8qazcccl"
)
assert result.address.to_bech32() == "erd1487vz5m4zpxjyqw4flwa3xhnkzg4yrr3mkzf5sf0zgt94hjprc8qazcccl"
assert result.username == ""

def test_get_fungible_token_of_account(self):
Expand Down Expand Up @@ -99,10 +99,7 @@ def test_get_definition_of_fungible_token(self):
result = self.proxy.get_definition_of_fungible_token("TEST-ff155e")

assert result.identifier == "TEST-ff155e"
assert (
result.owner.to_bech32()
== "erd1487vz5m4zpxjyqw4flwa3xhnkzg4yrr3mkzf5sf0zgt94hjprc8qazcccl"
)
assert result.owner.to_bech32() == "erd1487vz5m4zpxjyqw4flwa3xhnkzg4yrr3mkzf5sf0zgt94hjprc8qazcccl"
assert result.can_upgrade
assert not result.can_freeze
assert result.decimals == 6
Expand All @@ -112,10 +109,7 @@ def test_get_definition_of_token_collection(self):
result = self.proxy.get_definition_of_token_collection("NFTEST-ec88b8")

assert result.collection == "NFTEST-ec88b8"
assert (
result.owner.to_bech32()
== "erd1487vz5m4zpxjyqw4flwa3xhnkzg4yrr3mkzf5sf0zgt94hjprc8qazcccl"
)
assert result.owner.to_bech32() == "erd1487vz5m4zpxjyqw4flwa3xhnkzg4yrr3mkzf5sf0zgt94hjprc8qazcccl"
assert result.type == "NonFungibleESDT"
assert result.decimals == 0
assert not result.can_freeze
Expand All @@ -129,15 +123,9 @@ def test_get_transaction(self):
assert result.nonce == 0
assert result.block_nonce == 835600
assert result.epoch == 348
assert (
result.hash
== "9d47c4b4669cbcaa26f5dec79902dd20e55a0aa5f4b92454a74e7dbd0183ad6c"
)
assert result.is_completed == None
assert (
result.sender.to_bech32()
== "erd18s6a06ktr2v6fgxv4ffhauxvptssnaqlds45qgsrucemlwc8rawq553rt2"
)
assert result.hash == "9d47c4b4669cbcaa26f5dec79902dd20e55a0aa5f4b92454a74e7dbd0183ad6c"
assert result.is_completed is None
assert result.sender.to_bech32() == "erd18s6a06ktr2v6fgxv4ffhauxvptssnaqlds45qgsrucemlwc8rawq553rt2"
assert result.contract_results.items == []

def test_get_transaction_with_events(self):
Expand All @@ -155,12 +143,9 @@ def test_get_sc_invoking_tx(self):
"6fe05e4ca01d42c96ae5182978a77fe49f26bcc14aac95ad4f19618173f86ddb", True
)

assert result.is_completed == True
assert result.is_completed is True
assert len(result.contract_results.items) > 0
assert (
result.data
== "issue@54455354546f6b656e@54455354@016345785d8a0000@06@63616e4368616e67654f776e6572@74727565@63616e55706772616465@74727565@63616e4164645370656369616c526f6c6573@74727565"
)
assert result.data == "issue@54455354546f6b656e@54455354@016345785d8a0000@06@63616e4368616e67654f776e6572@74727565@63616e55706772616465@74727565@63616e4164645370656369616c526f6c6573@74727565"
assert sum([r.is_refund for r in result.contract_results.items]) == 1

def test_get_hyperblock(self):
Expand Down
6 changes: 6 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[pytest]
markers =
only: only run a specific test (run using: pytest -m "only")
networkInteraction: only run API and Proxy network providers tests (run using `pytest -m networkInteraction` or run all tests excepting these using: `pytest -m "not networkInteraction"`)

log_cli = True

0 comments on commit f5293ee

Please sign in to comment.