Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: Update to cratedb-toolkit 0.0.4, using upstream pytest fixture #78

Merged
merged 1 commit into from
Feb 10, 2024
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
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()
Loading