-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing: Export
cratedb_service
fixture as pytest11 entrypoint
This way, for basic needs, corresponding boilerplate code does not need to be provided by downstream projects. When needing more configurability, you will need to define corresponding alternative fixtures, and not use the built-in provided from.
- Loading branch information
Showing
4 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from typing import Generator | ||
|
||
import pytest | ||
|
||
from cratedb_toolkit.testing.testcontainers.cratedb import CrateDBTestAdapter | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def cratedb_service() -> Generator[CrateDBTestAdapter, None, None]: | ||
""" | ||
Provide a CrateDB service instance to the test suite. | ||
""" | ||
db = CrateDBTestAdapter() | ||
db.start() | ||
yield db | ||
db.stop() | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import re | ||
|
||
|
||
def test_cratedb_service(cratedb_service): | ||
""" | ||
Verify the exported pytest fixture `cratedb_service` works as intended. | ||
""" | ||
assert re.match(r"http://crate:@localhost:\d\d\d\d\d", cratedb_service.get_http_url()) | ||
assert re.match(r"crate://crate:@localhost:\d\d\d\d\d", cratedb_service.get_connection_url()) | ||
|
||
sql = "SELECT mountain FROM sys.summits ORDER BY prominence DESC LIMIT 1;" | ||
highest_summit = cratedb_service.database.run_sql(sql, records=True)[0] | ||
assert highest_summit["mountain"] == "Mont Blanc" |