Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/db_provider_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 18 additions & 3 deletions docs/dev/local_development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------------------
Expand Down
11 changes: 6 additions & 5 deletions tabletalk/tests/providers/test_mysql.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Any, Dict, Generator, Union

import mysql.connector
Expand All @@ -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]
Expand Down
11 changes: 6 additions & 5 deletions tabletalk/tests/providers/test_postgres.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Any, Dict, Generator

import pytest
Expand All @@ -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"),
}


Expand Down