6.0.0a3: Get rid of deprecated TokenEnable usage
This commit is contained in:
parent
8d00120a13
commit
278c121afd
|
@ -1,6 +1,6 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = sporestack
|
name = sporestack
|
||||||
version = 6.0.0a2
|
version = 6.0.0a3
|
||||||
description = SporeStack.com library and client. Launch servers with Monero or Bitcoin.
|
description = SporeStack.com library and client. Launch servers with Monero or Bitcoin.
|
||||||
long_description = file: README.md
|
long_description = file: README.md
|
||||||
long_description_content_type = text/markdown
|
long_description_content_type = text/markdown
|
||||||
|
|
|
@ -15,6 +15,8 @@ LATEST_API_VERSION = 3
|
||||||
|
|
||||||
|
|
||||||
class TokenEnable:
|
class TokenEnable:
|
||||||
|
"""Deprecated: Use TokenAdd instead."""
|
||||||
|
|
||||||
url = "/token/{token}/enable"
|
url = "/token/{token}/enable"
|
||||||
method = "POST"
|
method = "POST"
|
||||||
|
|
||||||
|
|
|
@ -234,21 +234,6 @@ def info(machine_id: str, api_endpoint: str = API_ENDPOINT) -> api.ServerInfo.Re
|
||||||
return response_object
|
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(
|
def token_add(
|
||||||
token: str,
|
token: str,
|
||||||
dollars: int,
|
dollars: int,
|
||||||
|
|
|
@ -479,7 +479,7 @@ def token_create(
|
||||||
typer.echo("Token already created! Did you mean to `topup`?", err=True)
|
typer.echo("Token already created! Did you mean to `topup`?", err=True)
|
||||||
raise typer.Exit(1)
|
raise typer.Exit(1)
|
||||||
|
|
||||||
response = api_client.token_enable(
|
response = api_client.token_add(
|
||||||
token=_token,
|
token=_token,
|
||||||
dollars=dollars,
|
dollars=dollars,
|
||||||
currency=currency,
|
currency=currency,
|
||||||
|
@ -500,7 +500,7 @@ def token_create(
|
||||||
# FIXME: Wait two hours in a smarter way.
|
# FIXME: Wait two hours in a smarter way.
|
||||||
# Waiting for payment to set in.
|
# Waiting for payment to set in.
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
response = api_client.token_enable(
|
response = api_client.token_add(
|
||||||
token=_token,
|
token=_token,
|
||||||
dollars=dollars,
|
dollars=dollars,
|
||||||
currency=currency,
|
currency=currency,
|
||||||
|
|
|
@ -87,15 +87,3 @@ def test_token_balance(mock_api_request: MagicMock) -> None:
|
||||||
mock_api_request.assert_called_once_with(
|
mock_api_request.assert_called_once_with(
|
||||||
url="https://api.sporestack.com/token/dummytoken/balance"
|
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…
Reference in New Issue