From 2c9435d70e82898585b741e468ecaffd9093a1c6 Mon Sep 17 00:00:00 2001 From: Bharath Thotakura <113555655+bharat-thotakura@users.noreply.github.com> Date: Thu, 12 Oct 2023 16:02:38 -0500 Subject: [PATCH] Update `get_balance()` return to credits (#815) --- cirq-superstaq/cirq_superstaq/service.py | 16 ---------------- cirq-superstaq/cirq_superstaq/service_test.py | 2 +- general-superstaq/general_superstaq/service.py | 2 +- .../general_superstaq/service_test.py | 2 +- .../qiskit_superstaq/daily_integration_test.py | 2 +- .../qiskit_superstaq/superstaq_provider_test.py | 2 +- 6 files changed, 5 insertions(+), 21 deletions(-) diff --git a/cirq-superstaq/cirq_superstaq/service.py b/cirq-superstaq/cirq_superstaq/service.py index 8d4ef2a10..64a0a9a82 100644 --- a/cirq-superstaq/cirq_superstaq/service.py +++ b/cirq-superstaq/cirq_superstaq/service.py @@ -388,22 +388,6 @@ def get_job(self, job_id: str) -> css.job.Job: """ return css.job.Job(client=self._client, job_id=job_id) - def get_balance(self, pretty_output: bool = True) -> Union[str, float]: - """Get the querying user's account balance in USD. - - Args: - pretty_output: Whether to return a pretty string or a float of the balance. - - Returns: - If `pretty_output` is `True`, returns the balance as a nicely formatted string - ($-prefix, commas on LHS every three digits, and two digits after period). Otherwise, - simply returns a float of the balance. - """ - balance = self._client.get_balance()["balance"] - if pretty_output: - return f"${balance:,.2f}" - return balance - def get_targets(self) -> Dict[str, List[str]]: """Gets a list of available, unavailable, and retired targets. diff --git a/cirq-superstaq/cirq_superstaq/service_test.py b/cirq-superstaq/cirq_superstaq/service_test.py index 7b5a0328d..129ecaa9a 100644 --- a/cirq-superstaq/cirq_superstaq/service_test.py +++ b/cirq-superstaq/cirq_superstaq/service_test.py @@ -245,7 +245,7 @@ def test_service_get_balance() -> None: mock_client.get_balance.return_value = {"balance": 12345.6789} service._client = mock_client - assert service.get_balance() == "$12,345.68" + assert service.get_balance() == "12,345.68 credits" assert service.get_balance(pretty_output=False) == 12345.6789 diff --git a/general-superstaq/general_superstaq/service.py b/general-superstaq/general_superstaq/service.py index 783721794..3b7808073 100644 --- a/general-superstaq/general_superstaq/service.py +++ b/general-superstaq/general_superstaq/service.py @@ -48,7 +48,7 @@ def get_balance(self, pretty_output: bool = True) -> Union[str, float]: balance = self._client.get_balance()["balance"] if pretty_output: - return f"${balance:,.2f}" + return f"{balance:,.2f} credits" return balance def _accept_terms_of_use(self, user_input: str) -> str: diff --git a/general-superstaq/general_superstaq/service_test.py b/general-superstaq/general_superstaq/service_test.py index 15ccb36ff..5b6e93445 100644 --- a/general-superstaq/general_superstaq/service_test.py +++ b/general-superstaq/general_superstaq/service_test.py @@ -16,7 +16,7 @@ def test_service_get_balance() -> None: mock_client.get_balance.return_value = {"balance": 12345.6789} service._client = mock_client - assert service.get_balance() == "$12,345.68" + assert service.get_balance() == "12,345.68 credits" assert service.get_balance(pretty_output=False) == 12345.6789 diff --git a/qiskit-superstaq/qiskit_superstaq/daily_integration_test.py b/qiskit-superstaq/qiskit_superstaq/daily_integration_test.py index a132ced96..d68af001b 100644 --- a/qiskit-superstaq/qiskit_superstaq/daily_integration_test.py +++ b/qiskit-superstaq/qiskit_superstaq/daily_integration_test.py @@ -101,7 +101,7 @@ def test_aqt_compile_eca_regression(provider: qss.SuperstaqProvider) -> None: def test_get_balance(provider: qss.SuperstaqProvider) -> None: balance_str = provider.get_balance() assert isinstance(balance_str, str) - assert balance_str.startswith("$") + assert balance_str.endswith("credits") assert isinstance(provider.get_balance(pretty_output=False), float) diff --git a/qiskit-superstaq/qiskit_superstaq/superstaq_provider_test.py b/qiskit-superstaq/qiskit_superstaq/superstaq_provider_test.py index e41031a41..40f3645e8 100644 --- a/qiskit-superstaq/qiskit_superstaq/superstaq_provider_test.py +++ b/qiskit-superstaq/qiskit_superstaq/superstaq_provider_test.py @@ -51,7 +51,7 @@ def test_get_balance() -> None: mock_client.get_balance.return_value = {"balance": 12345.6789} ss_provider._client = mock_client - assert ss_provider.get_balance() == "$12,345.68" + assert ss_provider.get_balance() == "12,345.68 credits" assert ss_provider.get_balance(pretty_output=False) == 12345.6789