Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Oct 25, 2023
1 parent 56b520c commit efad596
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 5 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/python-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,22 @@ jobs:
cd multicorn2
git checkout v2.5
pip install .
- name: Start the Postgres service
run: |
docker-compose -f postgres/docker-compose.yml up --build -d
- name: Check if Postgres is ready
run: |
docker run --network container:postgres_postgres_1 postgres_postgres pg_isready \
-h postgres \
-p 5432 \
-U shillelagh \
--timeout=30
- name: Test with pytest
env:
SHILLELAGH_ADAPTER_KWARGS: ${{ secrets.SHILLELAGH_ADAPTER_KWARGS }}
run: |
pytest --cov-fail-under=100 --cov=src/shillelagh -vv tests/ --doctest-modules src/shillelagh --with-integration --with-slow-integration
- name: Stop the Postgres service
if: always()
run: |
docker-compose -f postgres/docker-compose.yml down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ There is also an [experimental backend](https://shillelagh.readthedocs.io/en/lat
from shillelagh.backends.multicorn.db import connect
connection = connect(
username="username",
user="username",
password="password",
host="localhost",
port=5432,
Expand Down
57 changes: 57 additions & 0 deletions tests/adapters/api/gsheets/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from shillelagh.adapters.api.gsheets.types import SyncMode
from shillelagh.backends.apsw.db import connect
from shillelagh.backends.multicorn.db import connect as connect_multicorn


@pytest.mark.skip("Credentials no longer valid")
Expand Down Expand Up @@ -726,3 +727,59 @@ def test_weird_symbols(adapter_kwargs: Dict[str, Any]) -> None:
assert cursor.fetchall() == [(1.0, "a", 45.0), (2.0, "b", 1999.0)]
assert cursor.description is not None
assert [column[0] for column in cursor.description] == ['foo"', '"bar', 'a"b']


@pytest.mark.slow_integration_test
def test_public_sheet_apsw() -> None:
"""
Test reading values from a public sheet with APSW.
"""
table = (
'"https://docs.google.com/spreadsheets/d/'
'1LcWZMsdCl92g7nA-D6qGRqg1T5TiHyuKJUY1u9XAnsk/edit#gid=0"'
)

connection = connect(":memory:")
cursor = connection.cursor()
sql = f"SELECT * FROM {table}"
cursor.execute(sql)
assert cursor.fetchall() == [
("BR", 2),
("BR", 4),
("ZA", 7),
("CR", 11),
("CR", 11),
("FR", 100),
("AR", 42),
]


@pytest.mark.slow_integration_test
def test_public_sheet_multicorn() -> None:
"""
Test reading values from a public sheet with Multicorn2.
"""
table = (
'"https://docs.google.com/spreadsheets/d/'
'1LcWZMsdCl92g7nA-D6qGRqg1T5TiHyuKJUY1u9XAnsk/edit#gid=0"'
)

connection = connect_multicorn(
user="shillelagh",
password="shillelagh123",
host="localhost",
port=12345,
database="shillelagh",
)
cursor = connection.cursor()
sql = f"SELECT * FROM {table}"
cursor.execute(sql)
assert cursor.fetchall() == [
("BR", 2),
("BR", 4),
("ZA", 7),
("CR", 11),
("CR", 11),
("FR", 100),
("AR", 42),
]
8 changes: 4 additions & 4 deletions tests/backends/multicorn/db_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_connect(mocker: MockerFixture, registry: AdapterLoader) -> None:
connect(
None,
["dummy"],
username="username",
user="username",
password="password",
host="host",
port=1234,
Expand All @@ -40,7 +40,7 @@ def test_connect(mocker: MockerFixture, registry: AdapterLoader) -> None:
{},
"main",
),
username="username",
user="username",
password="password",
host="host",
port=1234,
Expand All @@ -60,7 +60,7 @@ def test_cursor_factory(mocker: MockerFixture) -> None:
"main",
)
assert cursor_factory(
username="username",
user="username",
password="password",
host="host",
port=1234,
Expand All @@ -69,7 +69,7 @@ def test_cursor_factory(mocker: MockerFixture) -> None:
adapters=["dummy"],
adapter_kwargs={},
schema="main",
username="username",
user="username",
password="password",
host="host",
port=1234,
Expand Down

0 comments on commit efad596

Please sign in to comment.