Skip to content

Commit

Permalink
Merge pull request #29 from supabase/j0_test_precommit
Browse files Browse the repository at this point in the history
Format unformatted files
  • Loading branch information
J0 authored May 26, 2021
2 parents 434d6ba + 4776baa commit 5f7b3bb
Showing 5 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit_hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pre-commit

on: [push]
on: [push, pull_request]

jobs:
build:
12 changes: 6 additions & 6 deletions supabase_py/client.py
Original file line number Diff line number Diff line change
@@ -7,10 +7,6 @@
from supabase_py.lib.realtime_client import SupabaseRealtimeClient
from supabase_py.lib.supabase_storage_client import SupabaseStorageClient


from typing import Any, Dict


DEFAULT_OPTIONS = {
"schema": "public",
"auto_refresh_token": True,
@@ -149,9 +145,13 @@ def get_subscriptions(self):
return self.realtime.channels

@staticmethod
def _init_realtime_client(realtime_url: str, supabase_key: str) -> SupabaseRealtimeClient:
def _init_realtime_client(
realtime_url: str, supabase_key: str
) -> SupabaseRealtimeClient:
"""Private method for creating an instance of the realtime-py client."""
return SupabaseRealtimeClient(realtime_url, {"params": {"apikey": supabase_key}})
return SupabaseRealtimeClient(
realtime_url, {"params": {"apikey": supabase_key}}
)

@staticmethod
def _init_supabase_auth_client(
14 changes: 10 additions & 4 deletions supabase_py/lib/storage/storage_bucket_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Any
from typing import Any, Dict

import requests
from requests import HTTPError
@@ -50,7 +50,9 @@ def create_bucket(self, id: str) -> Dict[str, Any]:
A unique identifier for the bucket you are creating.
"""
try:
response = requests.post(f"{self.url}/bucket", data={"id": id}, headers=self.headers)
response = requests.post(
f"{self.url}/bucket", data={"id": id}, headers=self.headers
)
response.raise_for_status()
except HTTPError as http_err:
print(f"HTTP error occurred: {http_err}") # Python 3.6
@@ -68,7 +70,9 @@ def empty_bucket(self, id: str) -> Dict[str, Any]:
The unique identifier of the bucket you would like to empty.
"""
try:
response = requests.post(f"{self.url}/bucket/{id}/empty", data={}, headers=self.headers)
response = requests.post(
f"{self.url}/bucket/{id}/empty", data={}, headers=self.headers
)
response.raise_for_status()
except HTTPError as http_err:
print(f"HTTP error occurred: {http_err}") # Python 3.6
@@ -87,7 +91,9 @@ def delete_bucket(self, id: str) -> Dict[str, Any]:
The unique identifier of the bucket you would like to delete.
"""
try:
response = requests.delete(f"{self.url}/bucket/{id}", data={}, headers=self.headers)
response = requests.delete(
f"{self.url}/bucket/{id}", data={}, headers=self.headers
)

response.raise_for_status()
except HTTPError as http_err:
4 changes: 3 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
@@ -26,7 +26,9 @@ def _assert_authenticated_user(data: Dict[str, Any]) -> None:
assert user.get("aud") == "authenticated"


@pytest.mark.xfail(reason="None of these values should be able to instanciate a client object")
@pytest.mark.xfail(
reason="None of these values should be able to instanciate a client object"
)
@pytest.mark.parametrize("url", ["", None, "valeefgpoqwjgpj", 139, -1, {}, []])
@pytest.mark.parametrize("key", ["", None, "valeefgpoqwjgpj", 139, -1, {}, []])
def test_incorrect_values_dont_instanciate_client(url: Any, key: Any) -> None:
5 changes: 0 additions & 5 deletions tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import pytest


import supabase_py

"""
@@ -10,12 +7,10 @@
"""



def test_dummy() -> None:
# Test auth component
assert True == True



def test_client_initialziation() -> None:
client = supabase_py.Client("http://testwebsite.com", "atestapi")

0 comments on commit 5f7b3bb

Please sign in to comment.