Skip to content

Commit

Permalink
Testing: Update to cratedb-toolkit 0.0.4, using upstream pytest fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Feb 10, 2024
1 parent 60d6aa8 commit 0f0be66
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,11 @@ release = [
"twine<5",
]
test = [
"cratedb-toolkit==0.0.3",
"cratedb-toolkit[testing]==0.0.4",
"pytest<9",
"pytest-asyncio-cooperative",
"pytest-cov<5",
"pytest-mqtt",
"testcontainers",
]
[project.urls]
changelog = "https://github.com/daq-tools/lorrystream/blob/main/CHANGES.rst"
Expand Down
33 changes: 4 additions & 29 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,14 @@
# See LICENSE file for more information.

import pytest
import sqlalchemy as sa
from cratedb_toolkit.testing.testcontainers.cratedb import CrateDBContainer

from lorrystream.util.common import setup_logging


class CrateDBFixture:
def __init__(self):
self.cratedb = None
self.setup()

def setup(self):
self.cratedb = CrateDBContainer("crate/crate:nightly")
self.cratedb.start()

def finalize(self):
self.cratedb.stop()

def reset(self):
database_url = self.cratedb.get_connection_url()
sa_engine = sa.create_engine(database_url)
with sa_engine.connect() as conn:
conn.exec_driver_sql("DROP TABLE IF EXISTS testdrive;")

def get_connection_url(self, *args, **kwargs):
return self.cratedb.get_connection_url(*args, **kwargs)


@pytest.fixture(scope="function")
def cratedb():
fixture = CrateDBFixture()
yield fixture
fixture.finalize()
@pytest.fixture
def cratedb(cratedb_service):
cratedb_service.reset(["testdrive"])
yield cratedb_service


setup_logging()

0 comments on commit 0f0be66

Please sign in to comment.