Skip to content

Commit

Permalink
Merge pull request #15 from yyolk/minor-rls-init
Browse files Browse the repository at this point in the history
0.1.0
  • Loading branch information
yyolk authored Nov 10, 2022
2 parents a5130a2 + c1a5603 commit 917eb2a
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 12 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <major.minor.patch>
# e.g.:
$ hatch version 0.1.0
Old: 0.0.10
New: 0.1.0
```






## TODO

Expand Down
1 change: 1 addition & 0 deletions about.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0"
35 changes: 24 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]" },
]
description = "A simple Dexie.Space API client"
dependencies = [
"uplink",
"base58",
packages = [
"dexie",
]
dynamic = [
"version",
"dependencies",
]
readme = "README.md"
requires-python = ">=3.10"
Expand All @@ -38,20 +40,26 @@ 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 = [
"pytest",
]

[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"
Expand All @@ -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",
]
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
base58
uplink
51 changes: 50 additions & 1 deletion tests/dexie.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 917eb2a

Please sign in to comment.