Skip to content

Commit 5b5b5c9

Browse files
author
Andrew Smith
authored
chore: rename package to supabase_functions (#37)
1 parent 555df53 commit 5b5b5c9

File tree

14 files changed

+42
-15
lines changed

14 files changed

+42
-15
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,18 @@ jobs:
8888
fetch-depth: 0
8989
token: ${{ secrets.SILENTWORKS_PAT }}
9090

91+
- name: Rename Project
92+
id: rename_project
93+
run: make rename_project
94+
95+
- name: Python Semantic Release
96+
id: release
97+
uses: python-semantic-release/[email protected]
98+
with:
99+
github_token: ${{ secrets.GITHUB_TOKEN }}
100+
91101
- name: Publish package distributions to PyPI
92102
uses: pypa/gh-action-pypi-publish@release/v1
93103
# NOTE: DO NOT wrap the conditional in ${{ }} as it will always evaluate to true.
94104
# See https://github.com/actions/runner/issues/1173
95-
if: needs.publish.release.outputs.released == 'true'
105+
if: steps.release.outputs.released == 'true'

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@ tests_only:
1616
poetry run pytest --cov=./ --cov-report=xml --cov-report=html -vv
1717

1818
build_sync:
19-
poetry run unasync supafunc tests
19+
poetry run unasync supabase_functions tests
20+
21+
rename_project: rename_package_dir rename_package
22+
23+
rename_package_dir:
24+
mv supabase_functions supafunc
25+
26+
rename_package:
27+
sed -i 's/supabase_functions/supafunc/g' pyproject.toml tests/_async/clients.py tests/_sync/clients.py tests/_async/test_function_client.py tests/_sync/test_function_client.py

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
## Installation
55

6-
`pip3 install supafunc`
6+
`pip3 install supabase_functions`
77

88
## Usage
99

@@ -12,7 +12,7 @@ Deploy your function as per documentation.
1212

1313
```python3
1414
import asyncio
15-
from supafunc import AsyncFunctionsClient
15+
from supabase_functions import AsyncFunctionsClient
1616
async def run_func():
1717
fc = AsyncFunctionsClient("https://<project_ref>.functions.supabase.co", {})
1818
res = await fc.invoke("payment-sheet", {"responseType": "json"})
File renamed without changes.
File renamed without changes.
File renamed without changes.

supafunc/_sync/functions_client.py renamed to supabase_functions/_sync/functions_client.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def set_auth(self, token: str) -> None:
4444

4545
self.headers["Authorization"] = f"Bearer {token}"
4646

47-
def invoke(self, function_name: str, invoke_options: Optional[Dict] = None) -> Dict:
47+
def invoke(
48+
self, function_name: str, invoke_options: Optional[Dict] = None
49+
) -> Union[Dict, bytes]:
4850
"""Invokes a function
4951
5052
Parameters
@@ -54,11 +56,6 @@ def invoke(self, function_name: str, invoke_options: Optional[Dict] = None) -> D
5456
`headers`: object representing the headers to send with the request
5557
`body`: the body of the request
5658
`responseType`: how the response should be parsed. The default is `json`
57-
58-
Returns
59-
-------
60-
Dict
61-
Dictionary with data
6259
"""
6360
headers = self.headers
6461
if invoke_options is not None:
File renamed without changes.
File renamed without changes.

tests/_async/clients.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from jwt import encode
22

3-
from supafunc import AsyncFunctionsClient
3+
from supabase_functions import AsyncFunctionsClient
44

55
GOTRUE_JWT_SECRET = "37c304f8-51aa-419a-a1af-06154e63707a"
66
FUNCTIONS_URL = "http://localhost:54321/functions/v1"

tests/_async/test_function_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from httpx import Response
44
from jwt import encode
55

6-
from supafunc.errors import FunctionsHttpError, FunctionsRelayError
6+
from supabase_functions.errors import FunctionsHttpError, FunctionsRelayError
77

88
from .clients import (
99
FUNCTIONS_URL,

tests/_sync/clients.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from jwt import encode
22

3-
from supafunc import SyncFunctionsClient
3+
from supabase_functions import SyncFunctionsClient
44

55
GOTRUE_JWT_SECRET = "37c304f8-51aa-419a-a1af-06154e63707a"
66
FUNCTIONS_URL = "http://localhost:54321/functions/v1"

tests/_sync/test_function_client.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from httpx import Response
44
from jwt import encode
55

6-
from supafunc.errors import FunctionsHttpError, FunctionsRelayError
6+
from supabase_functions.errors import FunctionsHttpError, FunctionsRelayError
77

88
from .clients import (
99
FUNCTIONS_URL,
@@ -68,5 +68,17 @@ def test_invoke_with_non_200_response():
6868
return_value=Response(404),
6969
side_effect=FunctionsHttpError("Http error!"),
7070
)
71-
with pytest.raises(FunctionsHttpError, match=r"Http error!"):
71+
with pytest.raises(FunctionsHttpError, match=r"Http error!") as exc:
7272
function_client().invoke(function_name="hello-world")
73+
assert exc.value.message == "Http error!"
74+
75+
76+
def test_relay_error_message():
77+
with respx.mock:
78+
respx.post(f"{FUNCTIONS_URL}/hello-world").mock(
79+
return_value=Response(200, headers={"x-relay-header": "true"}),
80+
side_effect=FunctionsRelayError("Relay error!"),
81+
)
82+
with pytest.raises(FunctionsRelayError, match=r"Relay error!") as exc:
83+
function_client().invoke(function_name="hello-world")
84+
assert exc.value.message == "Relay error!"

0 commit comments

Comments
 (0)