Skip to content

Commit

Permalink
refining pytest implementation for tests and e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
stat committed Jan 14, 2025
1 parent 038fcc5 commit f1dbc48
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ lint-fix:

.PHONY: test
test:
poetry run pytest -m "not e2e"
poetry run pytest

.PHONY: e2e
e2e:
poetry run pytest -m "e2e"
poetry run pytest -m "tests and e2e"

.PHONY: repl
repl:
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ known-first-party = ["cdp"]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q --cov=cdp --cov-report=term-missing"
addopts = "-ra -q --cov=cdp --cov-report=term-missing -m 'not e2e'"
testpaths = [
"tests",
]
markers = [
"e2e: marks tests as e2e, requiring env, deselect with '-m \"not e2e\"'",
"tests: tests",
"e2e: e2e tests, requiring env, deselect with '-m \"not e2e\"'",
]

[tool.coverage.run]
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pytest

factory_modules = [
f[:-3] for f in os.listdir("./tests/factories") if f.endswith(".py") and f != "__init__.py"
Expand Down
11 changes: 11 additions & 0 deletions tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def imported_wallet(wallet_data):
return Wallet.import_data(WalletData.from_dict(wallet_data))


@pytest.mark.tests
@pytest.mark.e2e
def test_wallet_data(wallet_data):
"""Test wallet data format and required values."""
expected = {
Expand All @@ -49,6 +51,7 @@ def test_wallet_data(wallet_data):
assert value is not None


@pytest.mark.tests
@pytest.mark.e2e
def test_wallet_import(wallet_data):
"""Test wallet import functionality."""
Expand All @@ -65,6 +68,7 @@ def test_wallet_import(wallet_data):
assert imported_wallet.default_address.address_id == default_address_id


@pytest.mark.tests
@pytest.mark.e2e
def test_wallet_faucet(imported_wallet):
"""Test wallet faucet with ETH."""
Expand All @@ -79,6 +83,7 @@ def test_wallet_faucet(imported_wallet):
assert final_eth_balance > initial_eth_balance


@pytest.mark.tests
@pytest.mark.e2e
def test_wallet_faucet_usdc(imported_wallet):
"""Test wallet faucet with USDC."""
Expand All @@ -93,6 +98,7 @@ def test_wallet_faucet_usdc(imported_wallet):
assert final_usdc_balance > initial_usdc_balance


@pytest.mark.tests
@pytest.mark.e2e
def test_wallet_transfer(imported_wallet):
"""Test wallet transfer."""
Expand All @@ -119,6 +125,7 @@ def test_wallet_transfer(imported_wallet):
assert final_dest_balance > initial_dest_balance


@pytest.mark.tests
@pytest.mark.e2e
def test_transaction_history(imported_wallet):
"""Test transaction history retrieval."""
Expand Down Expand Up @@ -147,6 +154,7 @@ def test_transaction_history(imported_wallet):
assert matching_tx.status.value == "complete"


@pytest.mark.tests
@pytest.mark.e2e
def test_wallet_export(imported_wallet):
"""Test wallet export."""
Expand Down Expand Up @@ -175,6 +183,7 @@ def test_wallet_export(imported_wallet):
os.unlink("test_seed.json")


@pytest.mark.tests
@pytest.mark.e2e
def test_wallet_addresses(imported_wallet):
"""Test wallet addresses retrieval."""
Expand All @@ -183,13 +192,15 @@ def test_wallet_addresses(imported_wallet):
assert imported_wallet.default_address in addresses


@pytest.mark.tests
@pytest.mark.e2e
def test_wallet_balances(imported_wallet):
"""Test wallet balances retrieval."""
balances = imported_wallet.balances()
assert balances.get("eth") > 0


@pytest.mark.tests
@pytest.mark.e2e
def test_historical_balances(imported_wallet):
"""Test historical balance retrieval."""
Expand Down

0 comments on commit f1dbc48

Please sign in to comment.