From 278c121afdbb7ca0807d90be692cbf7c1fabe679 Mon Sep 17 00:00:00 2001 From: SporeStack Date: Tue, 5 Apr 2022 14:56:47 +0000 Subject: [PATCH] 6.0.0a3: Get rid of deprecated TokenEnable usage --- setup.cfg | 2 +- src/sporestack/api.py | 2 ++ src/sporestack/api_client.py | 15 --------------- src/sporestack/cli.py | 4 ++-- tests/test_api_client.py | 12 ------------ 5 files changed, 5 insertions(+), 30 deletions(-) diff --git a/setup.cfg b/setup.cfg index bae3ee4..9f15aca 100644 --- a/setup.cfg +++ b/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 diff --git a/src/sporestack/api.py b/src/sporestack/api.py index 2b8d55e..64f35ea 100644 --- a/src/sporestack/api.py +++ b/src/sporestack/api.py @@ -15,6 +15,8 @@ LATEST_API_VERSION = 3 class TokenEnable: + """Deprecated: Use TokenAdd instead.""" + url = "/token/{token}/enable" method = "POST" diff --git a/src/sporestack/api_client.py b/src/sporestack/api_client.py index 09029ba..9392426 100644 --- a/src/sporestack/api_client.py +++ b/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, diff --git a/src/sporestack/cli.py b/src/sporestack/cli.py index 1fca439..4de2eeb 100644 --- a/src/sporestack/cli.py +++ b/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, diff --git a/tests/test_api_client.py b/tests/test_api_client.py index d981aaf..c4feb47 100644 --- a/tests/test_api_client.py +++ b/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, - )