From ab3d606676b459d0d4aec25e57f1a32fa76c2612 Mon Sep 17 00:00:00 2001 From: Joseph Chiocchi Date: Thu, 10 Nov 2022 15:29:09 -0600 Subject: [PATCH 1/6] switch to dynamic fields, re-add requirements.txt, add hatch-requirements.txt - switch to dynamic fields, version and dependencies will now be fed in dynamically; use `hatch version ...` commands - re-add requirements.txt; github actually picks up dependencies in requirements.txt and will show you as a user for a package; until it supports pyproject natively; lets re-add this - add plugin for hatch that will read requirements.txt and place it in dependencies --- about.py | 1 + pyproject.toml | 23 +++++++++++++++++------ requirements.txt | 2 ++ 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 about.py create mode 100644 requirements.txt 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..e04f7ba 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 = [ @@ -52,6 +62,7 @@ test = "pytest tests/*" # a separate test env, run with: # `hatch run +py=310 test:pytest` # +# not using this yet ;) [tool.hatch.envs.test] dependencies = [ "pytest" 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 From 4c5f7c9e941b4edc94791ce42c848d2aaea252ed Mon Sep 17 00:00:00 2001 From: Joseph Chiocchi Date: Thu, 10 Nov 2022 15:40:57 -0600 Subject: [PATCH 2/6] basic functional tests using mainnet --- pyproject.toml | 2 +- tests/dexie.py | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e04f7ba..9fabc4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ 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` diff --git a/tests/dexie.py b/tests/dexie.py index be76663..0a8a8fc 100644 --- a/tests/dexie.py +++ b/tests/dexie.py @@ -2,7 +2,49 @@ 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 From 2977f202db8d99b18ba3153c4951d181db4b6d4d Mon Sep 17 00:00:00 2001 From: Joseph Chiocchi Date: Thu, 10 Nov 2022 15:41:12 -0600 Subject: [PATCH 3/6] cleanup --- tests/dexie.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/dexie.py b/tests/dexie.py index 0a8a8fc..0dc55ef 100644 --- a/tests/dexie.py +++ b/tests/dexie.py @@ -2,13 +2,16 @@ 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=DEXIE_MAINNET) assert dc @@ -27,23 +30,27 @@ def test_get_offer(dexie_test_client): 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 From 2f239c0ccbff123a9af81ef9690df570533d87b7 Mon Sep 17 00:00:00 2001 From: Joseph Chiocchi Date: Thu, 10 Nov 2022 15:46:41 -0600 Subject: [PATCH 4/6] update README --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index d650929..a6fb358 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,30 @@ Decimal('30.43791071338040603262456230') ``` +# Development + +```sh +hatch env create +``` + + +## Tests + +```sh +hatch run test +``` + + +## Versioning + +```sh +hatch version +``` + + + + + ## TODO From 0c53ef5110717d888331a492145bafea2499af56 Mon Sep 17 00:00:00 2001 From: Joseph Chiocchi Date: Thu, 10 Nov 2022 15:50:08 -0600 Subject: [PATCH 5/6] update README --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a6fb358..e6766e3 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,11 @@ hatch run test ## Versioning ```sh -hatch version +# hatch version +# e.g.: +$ hatch version 0.1.0 +Old: 0.0.10 +New: 0.1.0 ``` From c1a5603be100ec133d1a4ed79d9d40452c0d5f1b Mon Sep 17 00:00:00 2001 From: Joseph Chiocchi Date: Thu, 10 Nov 2022 15:54:20 -0600 Subject: [PATCH 6/6] cleanup --- README.md | 6 ++++++ pyproject.toml | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e6766e3..0af3986 100644 --- a/README.md +++ b/README.md @@ -65,10 +65,16 @@ 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 diff --git a/pyproject.toml b/pyproject.toml index 9fabc4d..c53d5db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,10 +59,7 @@ dependencies = [ [tool.hatch.envs.default.scripts] test = "pytest tests/dexie.py" -# a separate test env, run with: -# `hatch run +py=310 test:pytest` -# -# not using this yet ;) +# not using this matrix env (yet) ;) [tool.hatch.envs.test] dependencies = [ "pytest" @@ -72,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", +]