[FEAT] cleanup GET /wallet endpoint, add wallet api routes (#1932)

* [FEAT] cleanup GET /wallet endpoint, add wallet api route
this removes the functionalitiy to create accounts and wallets via
the GET /wallet endpoint in generic.py

it add endpoints inside the api.py for it and the frontend is modified to use the api endpoints

this also simplifies for the `feat/login` for the route.

* remove stale generic tests and add api tests

* bug wrong endpoint create account

* vlad nitpick

* added checkif deleted is 404

* reload after renaming wallet

* another iteration with vlad

* create new wallet if it none exist

* fix delete refresh

* formatting
This commit is contained in:
dni ⚡
2023-09-25 14:06:00 +01:00
committed by GitHub
parent eb73daffe9
commit 5b16f54857
11 changed files with 158 additions and 164 deletions
+43 -3
View File
@@ -23,11 +23,51 @@ from ...helpers import (
WALLET = get_wallet_class()
# check if the client is working
# create account POST /api/v1/account
@pytest.mark.asyncio
async def test_core_views_generic(client):
response = await client.get("/")
async def test_create_account(client):
response = await client.post("/api/v1/account", json={"name": "test"})
assert response.status_code == 200
result = response.json()
assert "name" in result
assert result["name"] == "test"
assert "balance_msat" in result
assert "id" in result
assert "user" in result
# check POST and DELETE /api/v1/wallet with adminkey:
# create additional wallet and delete it
@pytest.mark.asyncio
async def test_create_wallet_and_delete(client, adminkey_headers_to):
response = await client.post(
"/api/v1/wallet", json={"name": "test"}, headers=adminkey_headers_to
)
assert response.status_code == 200
result = response.json()
assert "name" in result
assert result["name"] == "test"
assert "balance_msat" in result
assert "id" in result
assert "adminkey" in result
response = await client.delete(
"/api/v1/wallet",
headers={
"X-Api-Key": result["adminkey"],
"Content-type": "application/json",
},
)
assert response.status_code == 200
# get deleted wallet
response = await client.get(
"/api/v1/wallet",
headers={
"X-Api-Key": result["adminkey"],
"Content-type": "application/json",
},
)
assert response.status_code == 404
# check GET /api/v1/wallet with inkey: wallet info, no balance