diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index b499093..59622dd 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -5,7 +5,6 @@ name: Test and Release on: push: - pull_request: workflow_dispatch: jobs: @@ -40,7 +39,11 @@ jobs: SQLITE_DB: ${{ vars.SQLITE_DB }} SQLITE_PORT: ${{ vars.SQLITE_PORT }} run: | - pytest -v src/tests + pytest --cov -v src/tests + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} release: if: ${{ github.ref == 'refs/heads/main' }} needs: tests diff --git a/.gitignore b/.gitignore index fde26c3..9ee7dce 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ main.dSYM/ .env *.pyc *.pyo +.coverage .DS_Store diff --git a/README.md b/README.md index fd37b11..8d24a46 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # Python SDK for SQLite Cloud -![Build Status](https://github.com/sqlitecloud/python/actions/workflows/deploy.yaml/badge.svg "Build Status") ![Jupyter Notebook](https://img.shields.io/badge/jupyter-%23FA0F00.svg?style=plastic&logo=jupyter&logoColor=white) +![Build Status](https://github.com/sqlitecloud/python/actions/workflows/deploy.yaml/badge.svg "Build Status") +[![codecov](https://codecov.io/github/sqlitecloud/python/graph/badge.svg?token=38G6FGOWKP)](https://codecov.io/github/sqlitecloud/python) +![PyPI - Version](https://img.shields.io/pypi/v/sqlitecloud?link=https%3A%2F%2Fpypi.org%2Fproject%2FSqliteCloud%2F) +![PyPI - Downloads](https://img.shields.io/pypi/dm/sqlitecloud?link=https%3A%2F%2Fpypi.org%2Fproject%2FSqliteCloud%2F) +![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sqlitecloud?link=https%3A%2F%2Fpypi.org%2Fproject%2FSqliteCloud%2F) + + SQLiteCloud is a powerful Python package that allows you to interact with the SQLite Cloud backend server seamlessly. It provides methods for various database operations. This package is designed to simplify database operations in Python applications, making it easier than ever to work with SQLite Cloud. diff --git a/requirements-dev.txt b/requirements-dev.txt index 7139e51..1f30ce7 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,6 +2,8 @@ typing-extensions==4.1.1 pytest==7.0.1 pytest-mock==3.6.1 +pytest-cov==4.0.0 +coverage==6.2 python-dotenv==0.20.0 lz4==3.1.10 bump2version==1.0.1 diff --git a/src/sqlitecloud/driver.py b/src/sqlitecloud/driver.py index 15ae0b8..c1843dd 100644 --- a/src/sqlitecloud/driver.py +++ b/src/sqlitecloud/driver.py @@ -186,12 +186,12 @@ def _internal_pubsub_thread(self, connection: SQCloudConnect) -> None: ready_to_read, _, errors = select.select( [connection.pubsub_socket], [], [] ) - # eg, no data to read - if len(ready_to_read) == 0: - continue # eg, if the socket is closed if len(errors) > 0: break + # eg, no data to read + if len(ready_to_read) == 0: + continue data = connection.pubsub_socket.recv(blen) if not data: diff --git a/src/tests/integration/test_pubsub.py b/src/tests/integration/test_pubsub.py index 4b6cba5..fd1ba14 100644 --- a/src/tests/integration/test_pubsub.py +++ b/src/tests/integration/test_pubsub.py @@ -129,13 +129,13 @@ def assert_callback(conn, result, data): pubsub2 = SqliteCloudPubSub() pubsub2.notify_channel(connection2, channel, "message-in-a-bottle") + client.disconnect(connection2) + # wait for callback to be called flag.wait(30) assert callback_called - client.disconnect(connection2) - def test_listen_table_for_update(self, sqlitecloud_connection): connection, client = sqlitecloud_connection