Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions .github/workflows/publish-pypi.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/release-doctor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11.6
3.9.18
14 changes: 14 additions & 0 deletions scripts/apply-customizations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ find tests -name "*.py" -exec sed -i 's/from orb$/from orb_sdk/g' {} +
find tests -name "*.py" -exec sed -i 's/import orb\([^_]\)/import orb_sdk\1/g' {} +
find tests -name "*.py" -exec sed -i 's/import orb$/import orb_sdk/g' {} +

# Update mock.patch strings and error messages in tests
echo "Updating mock.patch and error message strings in tests/"
find tests -name "*.py" -exec sed -i "s/\"orb\._/\"orb_sdk._/g" {} +
find tests -name "*.py" -exec sed -i "s/'orb\._/'orb_sdk._/g" {} +

# Update scripts/lint import check
echo "Updating scripts/lint import check"
sed -i "s/python -c 'import orb'/python -c 'import orb_sdk'/" scripts/lint

# Remove pydantic v1 tests (we only use pydantic v2)
echo "Removing pydantic v1 tests from scripts/test"
sed -i '/Running Pydantic v1 tests/d' scripts/test
sed -i '/nox -s test-pydantic-v1/d' scripts/test

# Update pyproject.toml
echo "Updating pyproject.toml"
sed -i 's/name = "orb-billing"/name = "orb_sdk"/' pyproject.toml
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ echo "==> Running lints"
rye run lint

echo "==> Making sure it imports"
rye run python -c 'import orb'
rye run python -c 'import orb_sdk'
3 changes: 0 additions & 3 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,3 @@ export DEFER_PYDANTIC_BUILD=false

echo "==> Running tests"
rye run pytest "$@"

echo "==> Running Pydantic v1 tests"
rye run nox -s test-pydantic-v1 -- "$@"
24 changes: 12 additions & 12 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ def test_parse_retry_after_header(
calculated = client._calculate_retry_timeout(remaining_retries, options, headers)
assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType]

@mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, client: Orb) -> None:
respx_mock.post("/customers").mock(side_effect=httpx.TimeoutException("Test timeout error"))
Expand All @@ -762,7 +762,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, clien

assert _get_open_connections(client) == 0

@mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client: Orb) -> None:
respx_mock.post("/customers").mock(return_value=httpx.Response(500))
Expand All @@ -772,7 +772,7 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client
assert _get_open_connections(client) == 0

@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
@pytest.mark.parametrize("failure_mode", ["status", "exception"])
def test_retries_taken(
Expand Down Expand Up @@ -803,7 +803,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success

@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_omit_retry_count_header(self, client: Orb, failures_before_success: int, respx_mock: MockRouter) -> None:
client = client.with_options(max_retries=4)
Expand All @@ -826,7 +826,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0

@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_overwrite_retry_count_header(
self, client: Orb, failures_before_success: int, respx_mock: MockRouter
Expand All @@ -851,7 +851,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
assert response.http_request.headers.get("x-stainless-retry-count") == "42"

@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_retries_taken_new_response_class(
self, client: Orb, failures_before_success: int, respx_mock: MockRouter
Expand Down Expand Up @@ -1630,7 +1630,7 @@ async def test_parse_retry_after_header(
calculated = async_client._calculate_retry_timeout(remaining_retries, options, headers)
assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType]

@mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, async_client: AsyncOrb) -> None:
respx_mock.post("/customers").mock(side_effect=httpx.TimeoutException("Test timeout error"))
Expand All @@ -1642,7 +1642,7 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter,

assert _get_open_connections(async_client) == 0

@mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, async_client: AsyncOrb) -> None:
respx_mock.post("/customers").mock(return_value=httpx.Response(500))
Expand All @@ -1654,7 +1654,7 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter,
assert _get_open_connections(async_client) == 0

@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
@pytest.mark.parametrize("failure_mode", ["status", "exception"])
async def test_retries_taken(
Expand Down Expand Up @@ -1685,7 +1685,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success

@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_omit_retry_count_header(
self, async_client: AsyncOrb, failures_before_success: int, respx_mock: MockRouter
Expand All @@ -1710,7 +1710,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0

@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_overwrite_retry_count_header(
self, async_client: AsyncOrb, failures_before_success: int, respx_mock: MockRouter
Expand All @@ -1735,7 +1735,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
assert response.http_request.headers.get("x-stainless-retry-count") == "42"

@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_retries_taken_new_response_class(
self, async_client: AsyncOrb, failures_before_success: int, respx_mock: MockRouter
Expand Down
2 changes: 1 addition & 1 deletion tests/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_extract_response_type_direct_classes() -> None:
def test_extract_response_type_direct_class_missing_type_arg() -> None:
with pytest.raises(
RuntimeError,
match="Expected type <class 'orb._response.AsyncAPIResponse'> to have a type argument at index 0 but it did not",
match="Expected type <class 'orb_sdk._response.AsyncAPIResponse'> to have a type argument at index 0 but it did not",
):
extract_response_type(AsyncAPIResponse)

Expand Down