Skip to content

Commit

Permalink
move retries out of fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-ho committed Feb 24, 2024
1 parent c4fbef6 commit c075b81
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
21 changes: 13 additions & 8 deletions tests/integration/sql/conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from __future__ import annotations

import random
from typing import Generator

import numpy as np
import pytest
import sqlalchemy
import tenacity

TRINO_URL = "trino://user@localhost:8080/tpch"
URLS = {"trino": "trino://user@localhost:8080/tpch"}

NUM_TEST_ROWS = 200

Expand Down Expand Up @@ -36,10 +37,14 @@ def check_database_connection(url) -> None:


@pytest.fixture(scope="session")
@pytest.mark.parametrize("url", [TRINO_URL])
def check_db_server_initialized(url) -> bool:
try:
check_database_connection(url)
return True
except Exception as e:
pytest.fail(f"Failed to connect to {url}: {e}")
def db_url() -> Generator[str, None, None]:
for url in URLS.values():
try:
check_database_connection(url)
except Exception as e:
pytest.fail(f"Failed to connect to {url}: {e}")

def db_url(db):
return URLS[db]

yield db_url
15 changes: 15 additions & 0 deletions tests/integration/sql/test_databases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import annotations

import pandas as pd
import pytest

import daft


@pytest.mark.integration()
def test_trino_create_dataframe_ok(db_url) -> None:
url = db_url("trino")
df = daft.read_sql("SELECT * FROM tpch.sf1.nation", url)
pd_df = pd.read_sql("SELECT * FROM tpch.sf1.nation", url)

assert df.equals(pd_df)
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def temp_sqllite_db(test_items):
def test_sqllite_create_dataframe_ok(temp_sqllite_db) -> None:
df = daft.read_sql(
"SELECT * FROM iris", f"sqlite://{temp_sqllite_db}"
) # path here only has 2 slashes instead of 3 because connectorx is used
) # path here only has 2 slashes instead of 3 because connectorx uses 2 slashes
pd_df = pd.read_sql("SELECT * FROM iris", f"sqlite:///{temp_sqllite_db}")

assert df.to_pandas().equals(pd_df)
Expand Down
15 changes: 0 additions & 15 deletions tests/integration/sql/test_trino.py

This file was deleted.

0 comments on commit c075b81

Please sign in to comment.