Skip to content

Commit

Permalink
change /client/ -> /api/
Browse files Browse the repository at this point in the history
  • Loading branch information
marcorossi5 committed Nov 1, 2024
1 parent 8e90f73 commit d169593
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/qibo_client/qibo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def check_client_server_qibo_versions(self):
Raise assertion error if the two versions are not the same.
"""
url = self.base_url + "/client/qibo_version/"
url = self.base_url + "/api/qibo_version/"
response = QiboApiRequest.get(
url,
timeout=constants.TIMEOUT,
Expand Down Expand Up @@ -110,7 +110,7 @@ def _post_circuit(
device: str,
nshots: int = None,
) -> QiboJob:
url = self.base_url + "/client/run_circuit/"
url = self.base_url + "/api/run_circuit/"

payload = {
"token": self.token,
Expand Down Expand Up @@ -140,7 +140,7 @@ def _post_circuit(

def print_quota_info(self):
"""Logs the formatted user quota info table."""
url = self.base_url + "/client/info/quotas/"
url = self.base_url + "/api/info/quotas/"

payload = {
"token": self.token,
Expand Down Expand Up @@ -186,7 +186,7 @@ def print_quota_info(self):

def print_job_info(self):
"""Logs the formatted user quota info table."""
url = self.base_url + "/client/info/jobs/"
url = self.base_url + "/api/info/jobs/"

payload = {
"token": self.token,
Expand All @@ -209,7 +209,7 @@ def format_date(dt: str) -> str:
user_set = {job["user"]["email"] for job in jobs}
if len(user_set) > 1:
raise ValueError(
"The `/client/info/jobs/` endpoint returned info about "
"The `/api/info/jobs/` endpoint returned info about "
"multiple accounts."
)
user = list(user_set)[0]
Expand Down
20 changes: 10 additions & 10 deletions tests/test_qibo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def setup_and_teardown(self, monkeypatch):
@pytest.fixture
def pass_version_check(self, monkeypatch):
monkeypatch.setattr(f"{MOD}.qibo.__version__", FAKE_QIBO_VERSION)
endpoint = FAKE_URL + "/client/qibo_version/"
endpoint = FAKE_URL + "/api/qibo_version/"
response_json = {
"server_qibo_version": FAKE_QIBO_VERSION,
"minimum_client_qibo_version": FAKE_MINIMUM_QIBO_VERSION_ALLOWED,
Expand All @@ -67,7 +67,7 @@ def test_check_client_server_qibo_versions_raises_assertion_error(
):
monkeypatch.setattr(f"{MOD}.qibo.__version__", FAKE_QIBO_VERSION)

endpoint = FAKE_URL + "/client/qibo_version/"
endpoint = FAKE_URL + "/api/qibo_version/"
response_json = {
"server_qibo_version": "0.2.9",
"minimum_client_qibo_version": "0.2.8",
Expand Down Expand Up @@ -103,7 +103,7 @@ def test_check_client_server_qibo_versions_with_warning(self, monkeypatch, caplo
caplog.set_level(logging.WARNING)
monkeypatch.setattr(f"{MOD}.qibo.__version__", FAKE_QIBO_VERSION)

endpoint = FAKE_URL + "/client/qibo_version/"
endpoint = FAKE_URL + "/api/qibo_version/"
response_json = {
"server_qibo_version": "0.2.9",
"minimum_client_qibo_version": FAKE_MINIMUM_QIBO_VERSION_ALLOWED,
Expand All @@ -118,7 +118,7 @@ def test_check_client_server_qibo_versions_with_warning(self, monkeypatch, caplo
assert expected_log in caplog.messages

def test_run_circuit_with_invalid_token(self, pass_version_check):
endpoint = FAKE_URL + "/client/run_circuit/"
endpoint = FAKE_URL + "/api/run_circuit/"
message = "User not found, specify the correct token"
response_json = {"detail": message}
pass_version_check.add(responses.POST, endpoint, status=404, json=response_json)
Expand All @@ -130,7 +130,7 @@ def test_run_circuit_with_invalid_token(self, pass_version_check):
assert str(err.value) == expected_message

def test_run_circuit_with_job_post_error(self, pass_version_check):
endpoint = FAKE_URL + "/client/run_circuit/"
endpoint = FAKE_URL + "/api/run_circuit/"
message = "Server failed to post job to queue"
response_json = {"detail": message}
pass_version_check.add(responses.POST, endpoint, status=200, json=response_json)
Expand All @@ -142,7 +142,7 @@ def test_run_circuit_with_job_post_error(self, pass_version_check):

def test_run_circuit_with_success(self, pass_version_check, caplog):
caplog.set_level(logging.INFO)
endpoint = FAKE_URL + "/client/run_circuit/"
endpoint = FAKE_URL + "/api/run_circuit/"
response_json = {"pid": FAKE_PID}
pass_version_check.add(responses.POST, endpoint, status=200, json=response_json)

Expand All @@ -167,7 +167,7 @@ def test_run_circuit_with_success(self, pass_version_check, caplog):
def test_print_quota_info(self, caplog):
caplog.set_level(logging.INFO)

endpoint = FAKE_URL + "/client/info/quotas/"
endpoint = FAKE_URL + "/api/info/quotas/"
response_json = {
"disk_quota": {
"user": {"email": FAKE_USER_EMAIL},
Expand Down Expand Up @@ -223,7 +223,7 @@ def test_print_quota_info(self, caplog):
@responses.activate
def test_print_job_info_with_success(self, caplog):
caplog.set_level(logging.INFO)
endpoint = FAKE_URL + "/client/info/jobs/"
endpoint = FAKE_URL + "/api/info/jobs/"
fake_creation_date = "2000-01-01T00:00:00.128372Z"
formatted_creation_date = "2000-01-01 00:00:00"
fake_update_date = "2000-01-02T00:00:00.128372Z"
Expand Down Expand Up @@ -278,7 +278,7 @@ def test_print_job_info_with_success(self, caplog):
@responses.activate
def test_print_job_info_without_jobs(self, caplog):
caplog.set_level(logging.INFO)
endpoint = FAKE_URL + "/client/info/jobs/"
endpoint = FAKE_URL + "/api/info/jobs/"
responses.add(responses.POST, endpoint, status=200, json=[])

self.obj.print_job_info()
Expand All @@ -289,7 +289,7 @@ def test_print_job_info_without_jobs(self, caplog):
def test_print_job_info_raises_valuerror(self, caplog):
caplog.set_level(logging.INFO)

endpoint = FAKE_URL + "/client/info/jobs/"
endpoint = FAKE_URL + "/api/info/jobs/"
response_json = [
{
"pid": FAKE_PID + "1",
Expand Down

0 comments on commit d169593

Please sign in to comment.