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"), }