diff --git a/README.md b/README.md index d650929..0af3986 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,40 @@ Decimal('30.43791071338040603262456230') ``` +# Development + +```sh +hatch env create +``` + + +## Tests + +Run tests during development +```sh +hatch run test +``` + +Run tests with matrix in ci +```sh +hatch run +py=39,310 test:pytest +``` + + +## Versioning + +```sh +# hatch version +# e.g.: +$ hatch version 0.1.0 +Old: 0.0.10 +New: 0.1.0 +``` + + + + + ## TODO diff --git a/about.py b/about.py new file mode 100644 index 0000000..3dc1f76 --- /dev/null +++ b/about.py @@ -0,0 +1 @@ +__version__ = "0.1.0" diff --git a/pyproject.toml b/pyproject.toml index de0b087..c53d5db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,19 +8,21 @@ # [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-requirements.txt"] build-backend = "hatchling.build" [project] name = "dexie.py" -version = "0.0.10" authors = [ { name="Joseph Chiocchi", email="joe@yolk.cc" }, ] description = "A simple Dexie.Space API client" -dependencies = [ - "uplink", - "base58", +packages = [ + "dexie", +] +dynamic = [ + "version", + "dependencies", ] readme = "README.md" requires-python = ">=3.10" @@ -38,8 +40,16 @@ classifiers = [ "Homepage" = "https://github.com/yyolk/dexie.py" "Bug Tracker" = "https://github.com/yyolk/dexie.py/issues" +[tool.hatch.build.targets.wheel] +only-include = ["dexie.py"] + +[tool.hatch.version] +path = "about.py" + +# required for hatch-requirements.txt +[tool.hatch.metadata.hooks.requirements_txt] +files = ["requirements.txt"] -# I can do this with Hatch :D [tool.hatch.envs.default] dependencies = [ @@ -47,11 +57,9 @@ dependencies = [ ] [tool.hatch.envs.default.scripts] -test = "pytest tests/*" +test = "pytest tests/dexie.py" -# a separate test env, run with: -# `hatch run +py=310 test:pytest` -# +# not using this matrix env (yet) ;) [tool.hatch.envs.test] dependencies = [ "pytest" @@ -61,4 +69,9 @@ dependencies = [ test = "pytest tests/*" [[tool.hatch.envs.test.matrix]] -python = ["310", "311"] +python = [ + # keeping around for a minute, see #11 + "39", + "310", + "311", +] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4e08493 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +base58 +uplink diff --git a/tests/dexie.py b/tests/dexie.py index be76663..0dc55ef 100644 --- a/tests/dexie.py +++ b/tests/dexie.py @@ -3,6 +3,55 @@ import dexie +@pytest.fixture +def dexie_test_client(): + return dexie.Dexie(base_url=DEXIE_MAINNET) + + +DEXIE_MAINNET = "https://api.dexie.space" +DEXIE_TESTNET = "https://api-testnet.dexie.space" + + def test_bleak(): - dc = dexie.Dexie(base_url="https://api.dexie.space") + dc = dexie.Dexie(base_url=DEXIE_MAINNET) assert dc + + +def test_search_offers(dexie_test_client): + offers = dexie_test_client.search_offers(page_size=7) + assert offers + assert len(offers) == 7 + + +def test_get_offer(dexie_test_client): + # from api docs + dexie_offer_id = "HR7aHbCXsJto7iS9uBkiiGJx6iGySxoNqUGQvrZfnj6B" + offer = dexie_test_client.get_offer(dexie_offer_id) + assert offer + assert offer.status == 4 + + +def test_get_pairs(dexie_test_client): + pairs = dexie_test_client.get_pairs() + assert pairs + assert len(pairs) > 0 + + +def test_get_tickers(dexie_test_client): + ticker = dexie_test_client.get_tickers("XCH_DBX")[0] + assert ticker + assert ticker.last_price + assert ticker.pool_id + + +def test_get_orderbook(dexie_test_client): + req_depth = 6 + ob = dexie_test_client.get_orderbook("XCH_DBX", depth=req_depth) + assert ob + assert len(ob.bids) == req_depth / 2 + + +def test_get_historical_trades(dexie_test_client): + h_trades = dexie_test_client.get_historical_trades("XCH_DBX", limit=3) + assert h_trades + assert len(h_trades.trades) == 3