diff --git a/.github/workflows/db_provider_tests.yml b/.github/workflows/db_provider_tests.yml index 50d00a4..4503852 100644 --- a/.github/workflows/db_provider_tests.yml +++ b/.github/workflows/db_provider_tests.yml @@ -3,13 +3,12 @@ name: DB Provider Tests on: push: branches: [main] - pull_request_review: - types: [submitted] + pull_request: branches: [main] + workflow_dispatch: jobs: test: - if: github.event.review.state == 'approved' || github.event_name == 'push' runs-on: ubuntu-latest services: diff --git a/docs/dev/local_development.rst b/docs/dev/local_development.rst index 950becd..284153b 100644 --- a/docs/dev/local_development.rst +++ b/docs/dev/local_development.rst @@ -48,11 +48,26 @@ Development Workflow # or python -m tabletalk test -- Run tests: +Setting Up Test Environment +-------------------------- - .. code-block:: bash +1. Install test dependencies: + + .. code-block:: bash + + pip install -r requirements-dev.txt + +2. Configure database connections: + + - PostgreSQL and MySQL instances must be running locally + - You can configure the credentials within the test config for the providers in db_test_config.json + - You may set environment variables for the test config instead + +3. Run tests: + + .. code-block:: bash - pytest + pytest Building and Installing Locally ------------------------------ diff --git a/tabletalk/tests/providers/test_mysql.py b/tabletalk/tests/providers/test_mysql.py index 6a25037..fc9d968 100644 --- a/tabletalk/tests/providers/test_mysql.py +++ b/tabletalk/tests/providers/test_mysql.py @@ -1,3 +1,4 @@ +import os from typing import Any, Dict, Generator, Union import mysql.connector @@ -8,11 +9,11 @@ from tabletalk.providers.mysql_provider import MySQLProvider TEST_CONFIG = { - "host": "localhost", - "port": 3306, - "database": "test", - "user": "root", - "password": "test", + "host": os.getenv("MYSQL_TEST_HOST", "localhost"), + "port": int(os.getenv("MYSQL_TEST_PORT", "3306")), + "database": os.getenv("MYSQL_TEST_DB", "test"), + "user": os.getenv("MYSQL_TEST_USER", "root"), + "password": os.getenv("MYSQL_TEST_PASSWORD", "test"), } ConnectionType = Union[PooledMySQLConnection, MySQLConnectionAbstract] diff --git a/tabletalk/tests/providers/test_postgres.py b/tabletalk/tests/providers/test_postgres.py index 2cb5995..c340235 100644 --- a/tabletalk/tests/providers/test_postgres.py +++ b/tabletalk/tests/providers/test_postgres.py @@ -1,3 +1,4 @@ +import os from typing import Any, Dict, Generator import pytest @@ -6,11 +7,11 @@ from tabletalk.providers.postgres_provider import PostgresProvider TEST_CONFIG = { - "host": "localhost", - "port": 5432, - "dbname": "test_db", - "user": "test", - "password": "test", + "host": os.getenv("POSTGRES_TEST_HOST", "localhost"), + "port": int(os.getenv("POSTGRES_TEST_PORT", 5432)), + "dbname": os.getenv("POSTGRES_TEST_DB", "test_db"), + "user": os.getenv("POSTGRES_TEST_USER", "test"), + "password": os.getenv("POSTGRES_TEST_PASSWORD", "test"), }