Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Check

concurrency:
group: ${{ github.workflow }}.${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
workflow_call:

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
id: setup-python
with:
python-version: 3.13

- uses: snok/install-poetry@v1
with:
version: 1.8.4
virtualenvs-create: true
virtualenvs-in-project: true
virtualenvs-path: .venv
installer-parallel: true

- uses: actions/cache@v3
id: cached-poetry-dependencies
name: Virtual env cache
with:
path: ./.venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install project
run: poetry install --no-interaction

- name: Run tests
run: |
source .venv/bin/activate
python -m unittest tests/test_rest.py
env:
LNM_API_KEY: ${{ secrets.LNM_API_KEY }}
LNM_API_SECRET: ${{ secrets.LNM_API_SECRET }}
LNM_API_PASSPHRASE: ${{ secrets.LNM_API_PASSPHRASE }}
LNM_API_NETWORK: testnet
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.venv
__pycache__
.DS_Store
dist
dist
.env
2 changes: 2 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
],
"words": [
"cashin",
"dotenv",
"linkingpublickey",
"lnmarkets",
"lnurl",
"nostr",
"ohlcs",
"pipreqs",
"snok",
"stoploss",
"takeprofit",
"topt",
Expand Down
16 changes: 15 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ urls = { "Homepage" = "https://github.com/ln-markets/sdk-python" }
[tool.poetry.dependencies]
python = "^3.11"
requests = "^2.32.3"
python-dotenv = "^1.0.1"

[build-system]
requires = ["poetry-core"]
Expand Down
Empty file added tests/__init__.py
Empty file.
25 changes: 25 additions & 0 deletions tests/test_rest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import unittest
import os
from dotenv import load_dotenv

from lnmarkets import LNMClient
from lnmarkets.user import get_user

load_dotenv()

class TestRest(unittest.TestCase):
def test_rest(self):
client = LNMClient({
'network': 'testnet',
'key': os.getenv('LNM_API_KEY'),
'secret': os.getenv('LNM_API_SECRET'),
'passphrase': os.getenv('LNM_API_PASSPHRASE'),
})

user_info = get_user(client)

self.assertRegex(user_info['uid'], r'^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$')


if __name__ == '__main__':
unittest.main()