Browse Source

6.0.0a3: Get rid of deprecated TokenEnable usage

master 6.0.0a3
SporeStack 3 months ago
parent
commit
278c121afd
  1. 2
      setup.cfg
  2. 2
      src/sporestack/api.py
  3. 15
      src/sporestack/api_client.py
  4. 4
      src/sporestack/cli.py
  5. 12
      tests/test_api_client.py

2
setup.cfg

@ -1,6 +1,6 @@
[metadata]
name = sporestack
version = 6.0.0a2
version = 6.0.0a3
description = SporeStack.com library and client. Launch servers with Monero or Bitcoin.
long_description = file: README.md
long_description_content_type = text/markdown

2
src/sporestack/api.py

@ -15,6 +15,8 @@ LATEST_API_VERSION = 3
class TokenEnable:
"""Deprecated: Use TokenAdd instead."""
url = "/token/{token}/enable"
method = "POST"

15
src/sporestack/api_client.py

@ -234,21 +234,6 @@ def info(machine_id: str, api_endpoint: str = API_ENDPOINT) -> api.ServerInfo.Re
return response_object
def token_enable(
token: str,
dollars: int,
currency: str,
api_endpoint: str = API_ENDPOINT,
retry: bool = False,
) -> api.TokenEnable.Response:
request = api.TokenEnable.Request(dollars=dollars, currency=currency)
url = api_endpoint + api.TokenEnable.url.format(token=token)
response = _api_request(url=url, json_params=request.dict(), retry=retry)
response_object = api.TokenEnable.Response.parse_obj(response)
assert response_object.token == token
return response_object
def token_add(
token: str,
dollars: int,

4
src/sporestack/cli.py

@ -479,7 +479,7 @@ def token_create(
typer.echo("Token already created! Did you mean to `topup`?", err=True)
raise typer.Exit(1)
response = api_client.token_enable(
response = api_client.token_add(
token=_token,
dollars=dollars,
currency=currency,
@ -500,7 +500,7 @@ def token_create(
# FIXME: Wait two hours in a smarter way.
# Waiting for payment to set in.
time.sleep(10)
response = api_client.token_enable(
response = api_client.token_add(
token=_token,
dollars=dollars,
currency=currency,

12
tests/test_api_client.py

@ -87,15 +87,3 @@ def test_token_balance(mock_api_request: MagicMock) -> None:
mock_api_request.assert_called_once_with(
url="https://api.sporestack.com/token/dummytoken/balance"
)
@patch("sporestack.api_client._api_request")
def test_token_enable(mock_api_request: MagicMock) -> None:
with pytest.raises(ValidationError):
api_client.token_enable("dummytoken", currency="xmr", dollars=20)
json_params = {"currency": "xmr", "dollars": 20, "affiliate_token": None}
mock_api_request.assert_called_once_with(
url="https://api.sporestack.com/token/dummytoken/enable",
json_params=json_params,
retry=False,
)

Loading…
Cancel
Save