Skip to content

Commit

Permalink
fix: default value type for api url
Browse files Browse the repository at this point in the history
Copying fix by awoimbee on old repo
  • Loading branch information
tmpbeing committed Jan 17, 2024
1 parent 5e67d93 commit 9d022c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/ansys/simai/core/utils/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def prompt(cls, values):

class ClientConfig(BaseModel, extra="allow"):
url: HttpUrl = Field(
default="https://api.simai.ansys.com/v2/",
default=HttpUrl("https://api.simai.ansys.com/v2/"),
description="URL to the SimAI API.",
)
"URL to the SimAI API."
Expand Down Expand Up @@ -96,6 +96,8 @@ class ClientConfig(BaseModel, extra="allow"):

@validator("url", pre=True)
def clean_url(cls, url):
if isinstance(url, bytes):
url = url.decode()
url = urlunparse(urlparse(url))
if not url.endswith("/"):
url = url + "/"
Expand Down
3 changes: 2 additions & 1 deletion tests/test_core_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import pytest
import responses
from pydantic import HttpUrl

from ansys.simai.core import SimAIClient
from ansys.simai.core.errors import ApiClientError, NotFoundError
Expand All @@ -37,7 +38,7 @@ def test_construct_default_url():
skip_version_check=True,
organization="ExtraBanane",
)
assert client._api._url_prefix == "https://api.simai.ansys.com/v2/"
assert client._api._url_prefix == HttpUrl("https://api.simai.ansys.com/v2/")


@responses.activate
Expand Down

0 comments on commit 9d022c6

Please sign in to comment.