Skip to content

Conversation

@tinvaan
Copy link
Owner

@tinvaan tinvaan commented Feb 20, 2024

The current implementation of Supabase's sync and async client contains a ton of redundant code that is shared between both classes and should ideally reside under one class.

This PR is an attempt to unify the two client classes and host them in one single SupabaseClient class. A single client class should in theory be easier to maintain and an significantly bumps the project's code coverage(up to 63% from 44% earlier).

py39 run-test: commands[1] | poetry run pytest -s --disable-warnings --cov=./ --cov-report=term --cov-report=html
Test session starts (platform: darwin, Python 3.9.18, pytest 8.0.1, pytest-sugar 1.0.0)
cachedir: .tox/py39/.pytest_cache
rootdir: /Users/harish/Workspaces/oss/supabase/supabase-py
plugins: sugar-1.0.0, cov-4.1.0, anyio-4.2.0
collected 52 items

 tests/test_client.py xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx                                                                                             94% █████████▌
 tests/test_client_options.py ✓✓                                                                                                                                    98% █████████▊
 tests/test_function_configuration.py ✓                                                                                                                            100% ██████████

---------- coverage: platform darwin, python 3.9.18-final-0 ----------
Name                              Stmts   Miss  Cover
-----------------------------------------------------
scripts.py                           11     11     0%
supabase/__init__.py                  7      0   100%
supabase/__version__.py               1      0   100%
supabase/client/__init__.py          10      0   100%
supabase/client/auth.py              10      2    80%
supabase/client/default.py          106     45    58%
supabase/client/exceptions.py         4      2    50%
supabase/lib/__init__.py              3      0   100%
supabase/lib/client_options.py       33      0   100%
supabase/lib/realtime_client.py      29     20    31%
-----------------------------------------------------
TOTAL                               214     80    63%
Coverage HTML written to dir htmlcov


Results (0.21s):
       3 passed
      49 xfailed
____________________________________________________________________________________ summary _____________________________________________________________________________________
  py39: commands succeeded
  congratulations :)

@tinvaan tinvaan changed the title Unify sync and async clients [Needs testing] Unify sync and async clients Feb 20, 2024
@tinvaan tinvaan force-pushed the studio/tox-sync-async branch from 588c4c2 to eae626f Compare March 3, 2024 16:50
@tinvaan tinvaan force-pushed the studio/tox-sync-async branch from eae626f to 6244295 Compare March 5, 2024 03:16
@tinvaan tinvaan changed the title [Needs testing] Unify sync and async clients Unify sync and async clients Mar 8, 2024
@tinvaan
Copy link
Owner Author

tinvaan commented Mar 8, 2024

Test coverage is now up to 78% after the test suite revamp.

---------- coverage: platform darwin, python 3.9.18-final-0 ----------
Name                              Stmts   Miss  Cover
-----------------------------------------------------
scripts.py                           11     11     0%
supabase/__init__.py                  9      0   100%
supabase/__version__.py               1      0   100%
supabase/client/__init__.py          17      0   100%
supabase/client/default.py          133     24    82%
supabase/client/exceptions.py         4      0   100%
supabase/client/services.py          32      6    81%
supabase/lib/__init__.py              3      0   100%
supabase/lib/client_options.py       33      0   100%
supabase/lib/realtime_client.py      29     20    31%
-----------------------------------------------------
TOTAL                               272     61    78%
Coverage HTML written to dir htmlcov


Results (31.69s):
      17 passed
       1 skipped
  py39: OK (38.44=setup[3.35]+cmd[1.98,33.11] seconds)
  congratulations :) (38.50 seconds)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants