Skip to content

Commit 860653c

Browse files
tests: consolidate REST URL functional tests into test_server_rest.py
Co-authored-by: Junie <junie@jetbrains.com>
1 parent 5233bb1 commit 860653c

2 files changed

Lines changed: 43 additions & 45 deletions

File tree

tests/test_rest_url.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

tests/test_server_rest.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from borgstore.backends.rest import get_rest_backend
1616
from borgstore.backends.posixfs import get_file_backend
1717
from borgstore.backends.errors import ObjectNotFound, BackendAlreadyExists, QuotaExceeded
18-
from borgstore.store import get_backend
18+
from borgstore.store import get_backend, Store
1919

2020

2121
def start_server(backend_url, address, port, username=None, password=None, permissions=None, quota=None):
@@ -652,3 +652,45 @@ def do_request(method, path, body=b""):
652652
proc.wait(timeout=2)
653653
except subprocess.TimeoutExpired:
654654
proc.kill()
655+
656+
657+
def test_rest_url(tmp_path):
658+
repo_path = tmp_path / "repo"
659+
# Use rest: URL with stdio backend (empty host)
660+
url = f"rest:///{repo_path}"
661+
662+
# Use levels=0 to avoid root nesting issues if they arise
663+
config = {"": {"levels": [0]}}
664+
store = Store(url, config=config)
665+
store.create()
666+
667+
with store:
668+
item_name = "test-item"
669+
item_data = b"some data"
670+
store.store(item_name, item_data)
671+
672+
# Test Store.info which calls Backend.info (HEAD)
673+
# This used to hang.
674+
info = store.info(item_name)
675+
assert info.exists
676+
assert info.size == len(item_data)
677+
assert info.atime > 0
678+
679+
# Test listing
680+
items = list(store.list(""))
681+
assert len(items) == 1
682+
assert items[0].name == item_name
683+
assert items[0].atime > 0
684+
685+
# Test nonexistent item
686+
# This also used to hang if it returned a 404 with a body.
687+
info_none = store.info("nonexistent")
688+
assert not info_none.exists
689+
assert info_none.size == 0
690+
691+
# Test directory info (root)
692+
info_root = store.info("")
693+
assert info_root.exists
694+
assert info_root.directory
695+
696+
store.destroy()

0 commit comments

Comments
 (0)