Skip to content

Commit

Permalink
Add a test that opening two separate FDBs at the same time works
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHodson committed Oct 3, 2024
1 parent 584db5b commit d973261
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/test_passing_config_directly.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,50 @@ def test_direct_config():
# On OSX tmp file paths look like /private/var/folders/.../T/tmp.../x138-300.grib
# While the tmp directory looks like /var/folders/.../T/tmp.../ hence why this check is not "startwith"
assert tmp_root in list_output[0]["path"]


def test_opening_two_fdbs():
with TemporaryDirectory() as tmp_root1, TemporaryDirectory() as tmp_root2:
tests_dir = Path(__file__).parent

fdb1 = pyfdb.FDB(
dict(
type="local",
engine="toc",
schema=str(tests_dir / "default_fdb_schema"),
spaces=[
dict(
handler="Default",
roots=[
{"path": tmp_root1},
],
)
],
)
)

fdb2 = pyfdb.FDB(
dict(
type="local",
engine="toc",
schema=str(tests_dir / "default_fdb_schema"),
spaces=[
dict(
handler="Default",
roots=[
{"path": tmp_root2},
],
)
],
)
)

for fdb in [fdb1, fdb2]:
data = open(tests_dir / "x138-300.grib", "rb").read()
fdb.archive(data)
fdb.flush()

for fdb, root in [(fdb1, tmp_root1), (fdb2, tmp_root2)]:
list_output = list(fdb.list(keys=True))
assert len(list_output) == 1
assert root in list_output[0]["path"]

0 comments on commit d973261

Please sign in to comment.